我想比较单个Intel CPU核心的速度和单个nVidia GPU核心的速度(即:单个CUDA代码,单个线程).我确实实现了以下天真的2d图像卷积算法:
void convolution_cpu(uint8_t* res, uint8_t* img, uint32_t img_width, uint32_t img_height, uint8_t* krl, uint32_t krl_width, uint32_t krl_height)
{
int32_t center_x = krl_width / 2;
int32_t center_y = krl_height / 2;
int32_t sum;
int32_t fkx,fky;
int32_t xx,yy;
float krl_sum = 0;
for(uint32_t i = 0; i < krl_width*krl_height; ++i)
krl_sum += krl[i];
float nc = 1.0f/krl_sum;
for(int32_t y = 0; y < (int32_t)img_height; ++y)
{
for(int32_t x = 0; x < (int32_t)img_width; ++x)
{
sum = 0;
for(int32_t ky = …Run Code Online (Sandbox Code Playgroud) 我想nvcc -ptx从Windows命令行使用,但我总是收到此错误消息:nvcc:致命错误:无法找到Microsoft Visual Studio配置文件'vcvars64.bat'安装在'C:\ Program Files(x86)\ Microsoft Visual S tudio 11.0\VC\bin /../ ..'
我正在使用vs 2012快递版.什么可以解决方案?
我一直在按照本指南在我的El Capitan macbook pro上安装,使用CMake构建makefile.但是,当我尝试制作时,我遇到了错过cblas.h文件的错误.我成功重新安装了openblas:
$ brew uninstall openblas; brew install --fresh -vd openblas
并添加两个构建标志:
LDFLAGS: -L/usr/local/opt/openblas/lib
CPPFLAGS: -I/usr/local/opt/openblas/include
但是我仍然得到错误.然后我按照此处的建议重新安装了CUDA和xcode-select安装工具.
关于为什么make的任何建议/进一步推测都没有看到我的cblas.h文件,我们表示赞赏!
我需要在最小二乘意义上解决大量的线性系统.我有在理解的计算效率的差异麻烦numpy.linalg.lstsq(a, b),np.dot(np.linalg.pinv(a), b)和数学实施.
我使用以下矩阵:
h=np.random.random((50000,100))
a=h[:,:-1].copy()
b=-h[:,-1].copy()
Run Code Online (Sandbox Code Playgroud)
并且算法的结果是:
# mathematical implementation
%%timeit
np.dot(np.dot(np.linalg.inv(np.dot(a.T,a)),a.T),b)
Run Code Online (Sandbox Code Playgroud)
10个循环,最佳3:36.3 ms每个循环
# numpy.linalg.lstsq implementation
%%timeit
np.linalg.lstsq(a, b)[0]
Run Code Online (Sandbox Code Playgroud)
10个循环,最佳3:每循环103毫秒
%%timeit
np.dot(np.linalg.pinv(a), b)
Run Code Online (Sandbox Code Playgroud)
1个循环,最佳3:216 ms每个循环
为什么会有区别?
现在,我想使用cuda运行pytorch,然后我使用model.cuda(),并且torch.cuda.LongTensor()用于所有张量..cuda.如果我使用过,我是否必须明确使用张量model.cuda()?有没有办法让所有计算在GPU中运行为默认值?
在 ubuntu 16.04 中运行脚本时出现此错误。请耐心等待,我是 python 新手,我已经检查了互联网上已经可用的选项,但我无法修复它。
RuntimeError: cuda runtime error (10) : invalid device ordinal at torch/csrc/cuda/Module.cpp:32
Run Code Online (Sandbox Code Playgroud)
我目前正在运行这个文件。
from __future__ import print_function
from models import LipRead
import torch
import toml
from training import Trainer
from validation import Validator
print("Loading options...")
with open('options.toml', 'r') as optionsFile:
options = toml.loads(optionsFile.read())
if(options["general"]["usecudnnbenchmark"] and options["general"] ["usecudnn"]):
print("Running cudnn benchmark...")
torch.backends.cudnn.benchmark = True
#Create the model.
model = LipRead(options)
if(options["general"]["loadpretrainedmodel"]):
model.load_state_dict(torch.load(options["general"] ["pretrainedmodelpath"]))
#Move the model to the GPU.
if(options["general"]["usecudnn"]):
model = model.cuda(options["general"]["gpuid"])
trainer = Trainer(options) …Run Code Online (Sandbox Code Playgroud) >>> import tensorflow as tf
2020-07-08 17:10:50.005569: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
>>> tf.config.list_physical_devices('GPU')
2020-07-08 17:10:55.657489: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1050 computeCapability: 6.1
coreClock: 1.493GHz coreCount: 5 deviceMemorySize: 4.00GiB deviceMemoryBandwidth: 104.43GiB/s
2020-07-08 17:10:55.701387: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1703] Adding visible gpu devices: 0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
Run Code Online (Sandbox Code Playgroud)
in [1]: import tensorflow as tf
tf.config.list_physical_devices('GPU')
out[1]: []
in [1]: tf.__version__
out[1]: '2.2.0'
Run Code Online (Sandbox Code Playgroud) 哪个命令可以查看pytorchconda env 中看到的“正确”CUDA 版本? 这是一个类似的问题,但并没有让我走得更远。
nvidia-smi 说我有 cuda 版本 10.1
conda list 告诉我 cudatoolkit 版本是 10.2.89
torch.cuda.is_available()显示 FALSE,所以它看到No CUDA?
print(torch.cuda.current_device()), 我得到10.0.10(10010??) (看起来像):
断言错误:您系统上的 NVIDIA 驱动程序太旧(发现版本 10010)
print(torch._C._cuda_getCompiledVersion(), 'cuda compiled version')告诉我我的版本是10.0.20(10020??)?
10020 cuda编译版
为什么有这么多不同的版本?我错过了什么?
PS 我430在带有 Geforce 1050 的 Ubuntu 16.04 上libcuda1-430安装了Nvidia 驱动程序。当我从additional driversubuntu ( Software and Updates) 中的选项卡安装驱动程序时附带它。我安装pytorch
了conda其中还安装了cudatoolkit使用conda install -c fastai -c …
尝试在 python 虚拟环境中安装商店时遇到问题。特别是当
pip install shap
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
ERROR: Command errored out with exit status 1:
command: /Users/federiconutarelli/Desktop/Riccaboni_python/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/86/wyxlz8f56nq997hwmvpnt_km0000gn/T/pip-install-snwg2_4s/shap_4dbdc5c8e74a45cca2a3aa06af49ba31/setup.py'"'"'; __file__='"'"'/private/var/folders/86/wyxlz8f56nq997hwmvpnt_km0000gn/T/pip-install-snwg2_4s/shap_4dbdc5c8e74a45cca2a3aa06af49ba31/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/86/wyxlz8f56nq997hwmvpnt_km0000gn/T/pip-wheel-nnajc046
cwd: /private/var/folders/86/wyxlz8f56nq997hwmvpnt_km0000gn/T/pip-install-snwg2_4s/shap_4dbdc5c8e74a45cca2a3aa06af49ba31/
Complete output (224 lines):
The nvcc binary could not be located in your $PATH. Either add it to your path, or set $CUDAHOME to enable CUDA
Error building cuda module: TypeError('cannot unpack non-iterable NoneType object')
WARNING: Could not compile cuda extensions
running bdist_wheel …Run Code Online (Sandbox Code Playgroud) 我正在尝试在启用 GPU 的情况下在 Google Colab 上初始化张量。
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
t = torch.tensor([1,2], device=device)
Run Code Online (Sandbox Code Playgroud)
但我收到了这个奇怪的错误。
RuntimeError: CUDA error: device-side assert triggered CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace below might be incorrect. For debugging consider passing CUDA_LAUNCH_BLOCKING=1
即使将该环境变量设置为 1 似乎也没有显示任何进一步的细节。
有人遇到过这个问题吗?
python ×4
pytorch ×4
cuda ×2
caffe ×1
convolution ×1
database ×1
gpgpu ×1
gpu ×1
macos ×1
numpy ×1
nvcc ×1
performance ×1
tensor ×1
tensorflow ×1