When I run any torch to work with the GPU, I always get this error:
Traceback (most recent call last):
File “”, line 1, in
RuntimeError: CUDA error: out of memory
For example, when running …
CUDA_LAUNCH_BLOCKING=1 usr/bin/python3 -c "import torch; x = torch.linspace(0, 1, 10, device=torch.device(\"cuda:0\"))
Even if i select a GPU that has definitely memory left …
nvidia-smi -i 3
Wed Feb 16 21:13:11 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.32.03 Driver Version: 460.32.03 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 3 GeForce RTX 3090 On | 00000000:61:00.0 Off | N/A |
| 30% 26C P8 18W / 350W | 15MiB / 24268MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 3 N/A N/A 5084 G /usr/lib/xorg/Xorg 4MiB |
| 3 N/A N/A 11272 G /usr/lib/xorg/Xorg 4MiB |
| 3 N/A N/A 2461850 G /usr/lib/xorg/Xorg 4MiB |
+-----------------------------------------------------------------------------+
When running
CUDA_VISIBLE_DEVICES=3 CUDA_LAUNCH_BLOCKING=1 /usr/bin/python3 -c "import torch; x = torch.linspace(0, 1, 10, device=torch.device(\"cuda:0\"))"
, I get:
Traceback (most recent call last):
File “”, line 1, in
File “/home/chenkel/.local/lib/python3.8/site-packages/torch/cuda/init.py”, line 214, in _lazy_init
torch._C._cuda_init()
RuntimeError: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 2: out of memory
My torch version is 1.10.0+cu113
Cuda and driver version you can see from nvidida-smi
above.