Install the GCC compiler
| 1
 | sudo apt install gcc --fix-missing
 | 
 
| 1
 | sudo apt install nvidia-cuda-toolkit
 | 
 
check the Driver and CUDA versions
Install Python with Mamba
| 1
2
 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh
bash Miniforge3-Linux-x86_64.sh
 | 
 
| 1
2
3
 | mamba create -n mycuda jupyterlab -c conda-forge
mamba activate mycuda 
jupyter lab   
 | 
 
Testing Cuda
Search nvidia control panel, and select “Allow access to GPU performance counters to all users”
| 1
 | pip install torch numpy
 | 
 
|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 | 
import time
matrix_size = 32*128
x= torch.randn(matrix_size, matrix_size)
y= torch.randn(matrix_size,matrix_size)
print("***: CPU SPEED")
start = time.time()
result = torch.matmul(x,y)
print(time.time()- start)
print("verify device:",result.device)
x_gpu = x.to(device)
y_gpu =y.to(device)
torch.cuda.synchronize()
for i in range(1):
	print("---GPU SPEED---")
	start = time.time()
	result_gpu = torch.matmul(x_gpu, y_gpu)
	torch.cuda.synchronize()
	print(time.time()- start)
	print("verify device:",result_gpu.device)
 | 
 
output:
| 1
2
3
4
5
6
 | ***: CPU SPEED
0.19979572296142578
verify device: cpu
---GPU SPEED---
0.02033543586730957
verify device: cuda:0
 |