我的程序需要最大限度地使用 GPU。
那么,blockDim.x * blockIdx.x + threadIdx.x; 是吗?是否能够访问所有线程?或者也必须使用 .y 和 .z ?这是强制性的吗?
我编写了一个程序,用于在一组图像上使用gpu :: BroxOpticalFlow计算光流。在单线程执行的情况下,代码可以编译并正常运行。
由于我试图为光流计算找到最佳的参数配置,因此需要在同一组图像上多次运行代码。因此,为了加快处理速度,我决定使用多线程来并行运行具有不同参数的多个光流计算。为此,我只需为每个光流过程创建一个线程,并使用完全不同的对象和变量。
运行代码时,有时会从计算光流的gpu函数中获取以下运行时错误:
OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=77, file=/home/user/opencv-2.4.10/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu, line=1018
) in outputHandler, file /home/user/opencv-2.4.10/modules/gpu/src/optical_flow.cpp, line 72
OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=77, file=/home/user/opencv-2.4.10/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu, line=1018
) in outputHandler, file /home/user/opencv-2.4.10/modules/gpu/src/optical_flow.cpp, line 72
OpenCV Error: Gpu API call (NCV Assertion Failed: cudaError_t=77, file=/home/user/opencv-2.4.10/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu, line=1018
) in outputHandler, file /home/user/opencv-2.4.10/modules/gpu/src/optical_flow.cpp, line 72
OpenCV Error: Gpu API call (an illegal memory access was encountered) in copy, file /home/user/opencv-2.4.10/modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp, line 877 …Run Code Online (Sandbox Code Playgroud) (GTX 1080,Tensorflow 1.0.0)
在训练nvidia-smi输出期间(如下所示)表明,大多数情况下GPU 使用率均为0%(尽管使用了GPU)。关于我已经训练的时间,情况似乎是这样。偶尔,它有时会达到100%或类似的峰值。
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 375.26 Driver Version: 375.26 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 1080 Off | 0000:01:00.0 On | N/A |
| 33% 35C P2 49W / 190W | 7982MiB / 8110MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type …Run Code Online (Sandbox Code Playgroud) unsigned int a = 4294967295; // (2^32)-1
unsigned int b = 2;
Run Code Online (Sandbox Code Playgroud)
我试图找出获得两个无符号整数乘积的高 32 位的最有效方法。例如,使用 CUDA 编程我可以unsigned int first32bits = __umulhi(a,b)得到高 32 位。
有没有办法在 C++ 中做这样的事情?
这是我的方法:
unsigned long c = ( ((unsigned long)a * (unsigned long)b ) >> 32) & 0x00000000FFFFFFFF;
Run Code Online (Sandbox Code Playgroud)
有什么方法可以让我的方法更快吗?
我正在Windows 10上运行keras神经网络训练和GTX 1070预测.大多数时候它都在工作,但它不时会抱怨
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:359] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:366] error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows
E c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:326] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
F c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\core\kernels\conv_ops.cc:659] Check failed: stream->parent()->GetConvolveAlgorithms(&algorithms)
Run Code Online (Sandbox Code Playgroud)
它不能用字面上的错误含义和OOM错误来解释.
怎么修?
我正在尝试导入 tensorflow(使用 GPU)并不断收到以下错误:
导入错误:找不到“cudart64_80.dll”。TensorFlow 要求将此 DLL 安装在 %PATH% 环境变量中命名的目录中
设置:
环境变量:
我还在 %PATH% 变量中添加了以下内容:
我错过了什么?尽管在 %PATH% 中明确指定了它的位置,但为什么它找不到 cudart64_80.dll?
任何帮助将非常感激。
我正在使用这个 ffmpeg 命令(为简单起见,删除了值)
ffmpeg -hwaccel cuvid -c:v h264_cuvid -y -ss 1 -i "FILE0001.MOV" -ss 0 -i "GOPR0621.MP4" -filter_complex
[0:v][1:v]
midequalizer
[al];
[al]
yadif
lenscorrection
scale
[vl];
[1:v]
lenscorrection
scale
[vr];
[vl][vr]
hstack=shortest=1
-an -c:v h264_nvenc -preset slow "output.mp4"
Run Code Online (Sandbox Code Playgroud)
在带有 cuda 显卡的机器上。
我明白了
ffmpeg version N-90979-g08032331ac Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp …Run Code Online (Sandbox Code Playgroud) 我试图通过嵌入在计算机上重新执行GitHub项目以进行推荐,目的是在完成集成后首先嵌入存在于movieLens数据集中的用户和项目,然后使用内部产品来预测评分在所有组件中,我在训练中都出错了。
码:
from lightfm.datasets import fetch_movielens
movielens = fetch_movielens()
ratings_train, ratings_test = movielens['train'], movielens['test']
def _binarize(dataset):
dataset = dataset.copy()
dataset.data = (dataset.data >= 0.0).astype(np.float32)
dataset = dataset.tocsr()
dataset.eliminate_zeros()
return dataset.tocoo()
train, test = _binarize(movielens['train']), _binarize(movielens['test'])
class ScaledEmbedding(nn.Embedding):
""" Change the scale from normal to [0,1/embedding_dim] """
def reset_parameters(self):
self.weight.data.normal_(0, 1.0 / self.embedding_dim)
if self.padding_idx is not None:
self.weight.data[self.padding_idx].fill_(0)
class ZeroEmbedding(nn.Embedding):
def reset_parameters(self):
self.weight.data.zero_()
if self.padding_idx is not None:
self.weight.data[self.padding_idx].fill_(0)
class BilinearNet(nn.Module):
def __init__(self, num_users, num_items, embedding_dim, sparse=False):
super().__init__()
self.embedding_dim = …Run Code Online (Sandbox Code Playgroud) 我的张量流只打印出这一行:
I tensorflow/stream_executor/dso_loader.cc:152] successfully opened CUDA library libcublas.so.10.0 locally 运行时。
网上的Tensorflow日志有很多其他库正在加载,例如libcudnn。
因为我认为我的安装性能不是最佳,所以我试图找出是否是因为这个原因。任何帮助将不胜感激!
我的tf是1.13.1 NVIDIA驱动程序版本:418.67 CUDA版本:10.1(我还安装了10.0。这可能是问题吗?)
我怎么知道tensorflow张量是在cuda还是cpu中?以这个非常简单的例子为例:
import tensorflow as tf
tf.debugging.set_log_device_placement(True)
# Place tensors on the CPU
with tf.device('/device:GPU:0'):
a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
# print tensor a
print(a)
# Run on the GPU
c = tf.matmul(a, b)
print(c)
Run Code Online (Sandbox Code Playgroud)
代码运行良好。在这里,我将张量 'a' 和 'b' 物理放置在 GPU 上。在打印“a”时,我得到:
tf.Tensor(
[[1. 2. 3.]
[4. 5. 6.]], shape=(2, 3), dtype=float32)
Run Code Online (Sandbox Code Playgroud)
它不提供任何信息,无论是 CPU 还是 GPU 中的“a”。现在,假设有一个中间张量,如在某些操作期间创建的张量“c”。我怎么知道张量“c”是 CPU 还是 GPU 张量?另外,假设张量放置在 GPU 上。我怎样才能把它移到 CPU 上?