For the driver installation of NVIDIA graphics card, please refer to old text. After installing the driver, only one instruction is needed to complete the cuda environment setup.
sudo apt install nvidia-cuda-toolkit
The size is about 2G, which is equivalent to the size of the installation package downloaded from the official website. Then use nvcc -V to check and find that the latest CUDA10.0 is not installed, but CUDA9.1 is installed. The operating system is Ubuntu18.04LTS.
CUDA version
Then use the following code to test:
# include <stdio.h>
__ global__ voidhelloFromGPU(){printf("Hello, world! from GPU!\n");}
int main(){printf("Hello, world! from CPU!\n");
helloFromGPU <<<2,10>>>();cudaDeviceReset();return0;}
Use
nvcc HWGPU.cu -o HWGPU.o
command to compile, the running result is as follows:
operation result
Recommended Posts