【发布时间】:2021-11-28 11:59:41
【问题描述】:
我对安装在我的系统上并被我的软件有效使用的 CUDA 版本存有疑问。 我在网上做了一些研究,但找不到解决我疑问的方法。 对我的理解有所帮助并且与我将在下面提出的问题最相关的问题是this one。
问题描述:
我用 virtualenvironmentwrapper 创建了一个虚拟环境,然后我在其中安装了 pytorch。
一段时间后,我意识到我的系统上没有安装 CUDA。
您可以通过以下方式找到它:nvcc –V
如果没有返回,则表示您没有安装 CUDA(据我所知)。
因此,我按照说明here
我用this官方链接安装了CUDA。
然后,我简单地安装了nvidia-development-kit
sudo apt install nvidia-cuda-toolkit
现在,如果我在我的虚拟环境中这样做:
nvcc -V
我明白了:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
但是,如果(总是在虚拟环境中)我这样做:
python -c "import torch; print(torch.version.cuda)"
我明白了:
10.2
这是我不明白的第一件事。我在虚拟环境中使用的是哪个版本的 CUDA?
然后,如果我运行示例deviceQuery(来自cuda-samples 文件夹 - 可以通过以下this link 安装示例)我得到:
./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: "NVIDIA GeForce RTX 2080 Super with Max-Q Design"
CUDA Driver Version / Runtime Version 11.4 / 11.4
CUDA Capability Major/Minor version number: 7.5
Total amount of global memory: 7974 MBytes (8361279488 bytes)
(048) Multiprocessors, (064) CUDA Cores/MP: 3072 CUDA Cores
GPU Max Clock rate: 1080 MHz (1.08 GHz)
Memory Clock rate: 5501 Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 4194304 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total shared memory per multiprocessor: 65536 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1024
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 3 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Managed Memory: Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 1 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS
为什么现在提到 CUDA 11.4 版?是不是因为我用的是NVIDIA_CUDA-11.4_Samples?
另一个信息如下。如果我检查我的 /usr/local 文件夹,我会看到三个与 CUDA 相关的文件夹。
如果我这样做:
cd /usr/local && ll | grep -i CUDA
我明白了:
lrwxrwxrwx 1 root root 22 Oct 7 11:33 cuda -> /etc/alternatives/cuda/
lrwxrwxrwx 1 root root 25 Oct 7 11:33 cuda-11 -> /etc/alternatives/cuda-11/
drwxr-xr-x 16 root root 4096 Oct 7 11:33 cuda-11.4/
这正常吗?
感谢您的帮助。
【问题讨论】:
-
感谢您的评论和下面的回答,我很感激。为什么你认为我应该照你说的做?
-
是的,确实,我想一直在虚拟环境中工作
-
您也可以输入
which,例如which nvcc。这将告诉您您正在运行哪个程序。
标签: python linux pytorch cuda virtual-environment