Problem when using GPU

Hello everyone.

I just configured my GPU and I was trying to use Pytorch with CUDA.

I am facing quite a simple error I think.

I run:

import torch
a = torch.randn(10).cuda()

and i get:
Traceback (most recent call last):

File “<stdin>”, line 1, in <module>
File “/home/pablo/.local/lib/python2.7/site-packages/torch/_utils.py”, line 69, in cuda return new_type(self.size()).copy(self, async)
File “/home/pablo/.local/lib/python2.7/site-packages/torch/cuda/init.py”, line 358, in _lazy_new_lazy_init()
File “/home/pablo/.local/lib/python2.7/site-packages/torch/cuda/init.py”, line 120, in _lazy_init_check_driver()
File “/home/pablo/.local/lib/python2.7/site-packages/torch/cuda/init.py”, line 55, in _check_driver raise AssertionError(“Torch not compiled with CUDA enabled”)
AssertionError: Torch not compiled with CUDA enabled

I guess the solution is as simple as: Install Pytorch with CUDA. Hence I tried running:

pip install http://download.pytorch.org/whl/cu80/torch-0.3.0.post4-cp27-cp27mu-linux_x86_64.whl

which is Pytorch for Linux, with CUDA 8.0 and i get:

Requirement already satisfied: torch==0.3.0.post4 from http://download.pytorch.org/whl/cu80/torch-0.3.0.post4-cp27-cp27mu-linux_x86_64.whl in ./.local/lib/python2.7/site-packages
Requirement already satisfied: pyyaml in ./.local/lib/python2.7/site-packages (from torch==0.3.0.post4)
Requirement already satisfied: numpy in ./.local/lib/python2.7/site-packages (from torch==0.3.0.post4)

But running the what I wrote at the begining I have the same problem. Can anyone tell me what is happening?

Thank you very much in advance.

Firstly, could you check that you have nvidia driver correctly installed? Can you run nvidia-smi?

That’s what I get running that command:

Tue Jan 16 18:43:10 2018
±----------------------------------------------------------------------------+
| NVIDIA-SMI 384.111 Driver Version: 384.111 |
|-------------------------------±---------------------±---------------------+
| 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 GT 710 Off | 00000000:3B:00.0 N/A | N/A |
| 50% 41C P0 N/A / N/A | 0MiB / 2001MiB | N/A Default |
±------------------------------±---------------------±---------------------+
±----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
±----------------------------------------------------------------------------+

It seems you are using a GT 710, which should have compute capability 2.1. This might be too low. At least I had to upgrade my GTX 580, since I wasn’t able to use it.
Could someone confirm?

1 Like

I am not sure that is the information you are looking for.
I run “deviceQuery” and that’s the output I get:

./deviceQuery Starting…
CUDA Device Query (Runtime API) version (CUDART static linking)
Detected 1 CUDA Capable device(s)
Device 0: “GeForce GT 710”
CUDA Driver Version / Runtime Version 9.0 / 8.0
CUDA Capability Major/Minor version number: 3.5
Total amount of global memory: 2002 MBytes (2099118080 bytes)
( 1) Multiprocessors, (192) CUDA Cores/MP: 192 CUDA Cores
GPU Max Clock rate: 954 MHz (0.95 GHz)
Memory Clock rate: 800 Mhz
Memory Bus Width: 64-bit
L2 Cache Size: 524288 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(65536), 2D=(65536, 65536), 3D=(4096, 4096, 4096)
Maximum Layered 1D Texture Size, (num) layers 1D=(16384), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(16384, 16384), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 2048
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 1 copy engine(s)
Run time limit on kernels: No
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 PCI Domain ID / Bus ID / location ID: 0 / 59 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 9.0, CUDA Runtime Version = 8.0, NumDevs = 1, Device0 = GeForce GT 710
Result = PASS

Compute capability is 3.5 (or am I looking the wrong information?).

Yeah, you are right. Apparently I was looking at the 710m.
Since Pytorch needs compute capability >=3.0, you should be fine.

What does torch.cuda.is_available() return?
Have you tried to reinstall Pytorch?

Solved!

I thought I had reinstall Pytorch, but apparently I had left some files around, so when I reinstalled it told me it was already installed…

Now runing torch.cuda.is_available() i get True.

Thank you very much!!

I’m glad you solved it!
Sorry for the confusion I created about your GPU :wink: