How do I get my CUDA specs on a Linux machine?
If you can find where the CUDA SDK directory has been installed then you can just run the deviceQuery
example which will tell you all you need to know and more. The executable should be at $(SDK)/C/bin/linux/release/deviceQuery
- if it's not there then you may need to build the samples first:
$ cd $(SDK)
$ make
$ ./C/bin/linux/release/deviceQuery
The CUDA SDK directory is typically named NVIDIA_GPU_Computing_SDK
(more recent CUDA versions) or just NVIDIA_CUDA_SDK
(older CUDA versions).
How to get the CUDA version?
As Jared mentions in a comment, from the command line:
nvcc --version
(or /usr/local/cuda/bin/nvcc --version
) gives the CUDA compiler version (which matches the toolkit version).
From application code, you can query the runtime API version with
cudaRuntimeGetVersion()
or the driver API version with
cudaDriverGetVersion()
As Daniel points out, deviceQuery is an SDK sample app that queries the above, along with device capabilities.
As others note, you can also check the contents of the version.txt
using (e.g., on Mac or Linux)
cat /usr/local/cuda/version.txt
However, if there is another version of the CUDA toolkit installed other than the one symlinked from /usr/local/cuda
, this may report an inaccurate version if another version is earlier in your PATH
than the above, so use with caution.
How to get card specs programmatically in CUDA
You can use the cudaGetDeviceCount and cudaGetDeviceProperties APIs.
void DisplayHeader()
{
const int kb = 1024;
const int mb = kb * kb;
wcout << "NBody.GPU" << endl << "=========" << endl << endl;
wcout << "CUDA version: v" << CUDART_VERSION << endl;
wcout << "Thrust version: v" << THRUST_MAJOR_VERSION << "." << THRUST_MINOR_VERSION << endl << endl;
int devCount;
cudaGetDeviceCount(&devCount);
wcout << "CUDA Devices: " << endl << endl;
for(int i = 0; i < devCount; ++i)
{
cudaDeviceProp props;
cudaGetDeviceProperties(&props, i);
wcout << i << ": " << props.name << ": " << props.major << "." << props.minor << endl;
wcout << " Global memory: " << props.totalGlobalMem / mb << "mb" << endl;
wcout << " Shared memory: " << props.sharedMemPerBlock / kb << "kb" << endl;
wcout << " Constant memory: " << props.totalConstMem / kb << "kb" << endl;
wcout << " Block registers: " << props.regsPerBlock << endl << endl;
wcout << " Warp size: " << props.warpSize << endl;
wcout << " Threads per block: " << props.maxThreadsPerBlock << endl;
wcout << " Max block dimensions: [ " << props.maxThreadsDim[0] << ", " << props.maxThreadsDim[1] << ", " << props.maxThreadsDim[2] << " ]" << endl;
wcout << " Max grid dimensions: [ " << props.maxGridSize[0] << ", " << props.maxGridSize[1] << ", " << props.maxGridSize[2] << " ]" << endl;
wcout << endl;
}
}
If you have installed the GPU Computing SDK, have a look at the deviceQuery
project which can be found in the %NVSDKCOMPUTE_ROOT%\C\src
directory. It shows how to query for all the device properties using CUDA Runtime API calls.
The CUDA Programming guide has more detail in section 3.2.3.
CUDA: get required compute capabilities from binary
Running cuobjdump
should help you out here. It will tell you what ptx (code for jit compiling at runtime) is available in a compiled file and what sass (real code that gets executed on a specific device) has been precompiled as well. Below an example output for device code compiled with -arch=sm_20
:
$ cuobjdump quick
Fatbin elf code:
================
arch = sm_20
code version = [1,7]
producer = <unknown>
host = linux
compile_size = 64bit
identifier = quick.cu
Fatbin elf code:
================
arch = sm_20
code version = [1,7]
producer = cuda
host = linux
compile_size = 64bit
identifier = quick.cu
Fatbin ptx code:
================
arch = sm_20
code version = [4,1]
producer = cuda
host = linux
compile_size = 64bit
compressed
identifier = quick.cu
ptxasOptions = --generate-line-info
Pytorch says that CUDA is not available (on Ubuntu)
PyTorch doesn't use the system's CUDA library. When you install PyTorch using the precompiled binaries using either pip
or conda
it is shipped with a copy of the specified version of the CUDA library which is installed locally. In fact, you don't even need to install CUDA on your system to use PyTorch with CUDA support.
There are two scenarios which could have caused your issue.
You installed the CPU only version of PyTorch. In this case PyTorch wasn't compiled with CUDA support so it didn't support CUDA.
You installed the CUDA 10.2 version of PyTorch. In this case the problem is that your graphics card currently uses the 418.87 drivers, which only support up to CUDA 10.1. The two potential fixes in this case would be to either install updated drivers (version >= 440.33 according to Table 2) or to install a version of PyTorch compiled against CUDA 10.1.
To determine the appropriate command to use when installing PyTorch you can use the handy widget in the "Install PyTorch" section at pytorch.org. Just select the appropriate operating system, package manager, and CUDA version then run the recommended command.
In your case one solution was to use
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
which explicitly specifies to conda that you want to install the version of PyTorch compiled against CUDA 10.1.
For more information about PyTorch CUDA compatibility with respect drivers and hardware see this answer.
Edit After you added the output of collect_env
we can see that the problem was that you had the CUDA 10.2 version of PyTorch installed. Based on that an alternative solution would have been to update the graphics driver as elaborated in item 2 and the linked answer.
How to verify CuDNN installation?
Installing CuDNN just involves placing the files in the CUDA directory. If you have specified the routes and the CuDNN option correctly while installing caffe it will be compiled with CuDNN.
You can check that using cmake
. Create a directory caffe/build
and run cmake ..
from there. If the configuration is correct you will see these lines:
-- Found cuDNN (include: /usr/local/cuda-7.0/include, library: /usr/local/cuda-7.0/lib64/libcudnn.so)
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_30
-- cuDNN : Yes
If everything is correct just run the make
orders to install caffe from there.
How to change CUDA version
Change your CUDA soft link to point on your desired CUDA version. For example:
ll /usr/local/cuda
lrwxrwxrwx 1 root root 19 Sep 06 2017 /usr/local/cuda -> /usr/local/cuda-8.0/
Simply relink it with
Update:
If the symlink already exists, use this other command:
[jalal@goku ~]$ ls /usr/local/cuda
lrwxrwxrwx. 1 root root 20 Sep 14 08:03 /usr/local/cuda -> /usr/local/cuda-10.2
[jalal@goku ~]$ sudo ln -sfT /usr/local/cuda/cuda-11.1/ /usr/local/cuda
[jalal@goku ~]$ ls /usr/local/cuda
lrwxrwxrwx. 1 root root 26 Sep 14 13:25 /usr/local/cuda -> /usr/local/cuda/cuda-11.1/
ln -s /usr/local/cuda-7.5 /usr/local/cuda
(With the proper installation location)
Related Topics
Why Doesn't Tar Preserve File Permissions
Siege Aborted Due to Excessive Socket Failure
Writing a Syscall to Count Context Switches of a Process
How to Get Errno When Epoll_Wait Returns Epollerr
Using "Touch" to Create Directories
How to Run a Windows Docker Container on Linux Host
Trouble with Vagrant - "404 - Not Found"
How to Check Character Encoding of a File in Linux
What Is Eof!! in The Bash Script
Os X Permission Denied for /Usr/Local/Lib
Openssl/Rsa - Using a Public Key to Decrypt
What Is The Fastest Way to Display an Image in Qt on X11 Without Opengl
Convert Column to Matrix Format Using Awk
How Does The Os Know The Real Size of The Physical Memory