CUDA (Compute Unified Devices Architecture) is a software and hardware integration technology developed by NVIDIA (NVIDIA). It is the company’s solution for the integration of software and hardware. The official name of GPGPU. Through this technology, users can use NVIDIA’s GPU to perform operations other than image processing, and it is also the first time that GPUs can be used as a development environment for C-compilers. The CUDA Toolkit can only compile its own CUDA C-language (for OpenCL, which only has the function of linking[2]), that is, the part executed on the GPU is compiled intoPTXintermediate languageor The machine code for a specific NVIDIA GPU architecture (officially known as “# 8220″ by NVIDIA); device code” ); And executed in thecentral processing unitsection ofC / The C++code (officially known as “# 8220″ by NVIDIA); host code” )Still relying on external compilers, such asrequired under Microsoft Windows< a href=”https://zh.wikipedia.org/wiki/Microsoft_Visual_Studio”>Microsoft Visual Studio; Under Linux, it mainly relies on GCC.
Although CUDA is primarily built on C/C++and compiled using “NVCC” – NVIDIA’s LLVM based C/C++compiler interface, engineers can also manipulate the CUDA platform using compiler instructions (such as OpenACC) and various programming language extensions. Fortran engineers can compile using “CUDA Fortran” or the PGI CUDA Fortran compiler fromPGIcompany. In addition, the CUDA platform also supports other computing interfaces, such as Khronos Group’s OpenCL, Microsoft’s DirectCompute, and C++AMP. CUDA can also be indirectly called through interfaces in other languages such as Python, Perl, Java, Ruby, Lua, Haskell, MATLAB, IDL, and Mathematica.



wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/x86_64/cuda-ubuntu2404.pin
sudo mv cuda-ubuntu2404.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/12.9.1/local_installers/cuda-repo-ubuntu2404-12-9-local_12.9.1-575.57.08-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2404-12-9-local_12.9.1-575.57.08-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2404-12-9-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda-toolkit-12-9

/usr/local/cuda-12.9/bin/nvcc –version

dpkg -l | grep cuda

nvidia-smi
Check the installation status of CUDA and the specific packages installed through the above steps. Note that nvcc in the specific path needs to be used because it has not been added to the environment variable.
Edit. bashrc file
nano ~/.bashrc
Add these two lines at the end
export PATH=/usr/local/cuda-12.9/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:$LD_LIBRARY_PATH

Change of application environment variables
source ~/.bashrc
After adding, you can directly call nvcc and check by checking the version number.
nvcc --version

Reference link
https://zh.wikipedia.org/wiki/CUDA
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#local -repo-installation-for-wsl
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/#meta -packages
Published on July 13, 2025
