# How to Install NVIDIA CUDA Toolkit on Atlantic.Net GPU Server

> URL: https://www.atlantic.net/gpu-server-hosting/how-to-install-nvidia-cuda-toolkit-on-atlantic-cloud-gpu-server/ | Published: 2024-12-04 | Updated: 2024-12-12 | Author: Hitesh Jethva

The NVIDIA CUDA Toolkit is a powerful development suite for accelerating computationally intensive applications using the GPU’s parallel processing capabilities. CUDA, short for Compute Unified Device Architecture, is a parallel computing platform and programming model developed by NVIDIA. It allows developers to leverage the processing power of NVIDIA GPUs (Graphics Processing Units) to perform general-purpose computing tasks that go beyond graphics rendering.

CUDA is particularly important for high-performance computing, artificial intelligence (AI), machine learning (ML), and deep learning applications. It provides developers with a software environment for writing applications that can run in parallel on thousands of GPU cores, offering significant speed improvements compared to traditional CPU-based computations.

In this guide, we’ll show you how to install and setup the NVIDIA CUDA Toolkit on your Atlantic.Net GPU server.

## Prerequisites

- An Ubuntu 22.04 GPU Server
- A root or sudo privileges

## Step 1: Update System Packages

Start by updating the system package list to ensure your environment is equipped with the latest updates and patches.

```bash
apt update -y
```

## Step 2: Verify Your GPU Compatibility

To confirm that your GPU supports CUDA, run the following command:

```bash
lspci | grep -i nvidia
```

This command lists all NVIDIA GPUs detected by your system. Example output:

```bash
06:00.0 VGA compatible controller: NVIDIA Corporation GA102GL [A40] (rev a1)
```

If the output lists an NVIDIA GPU, your system is CUDA-compatible. If no NVIDIA GPU is listed, update the PCI hardware database and rerun the lspci command:

```bash
update-pciids
```

## Step 3: Check GCC Compiler Version

CUDA requires a supported version of the GNU Compiler Collection (GCC). Verify the installed version with:

```bash
gcc --version
```

Example output:

```bash
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

If your GCC version is outdated, install or update it using:

```bash
apt install gcc -y
```

## Step 4: Download and Install NVIDIA CUDA Toolkit

Visit the [**CUDA Toolkit Archive files page**](https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64) and download the NVIDIA CUDA keyring using the below command.

```bash
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
```

Install the downloaded package with dpkg command:

```bash
dpkg -i cuda-keyring_1.1-1_all.deb
```

Refresh the package index to recognize NVIDIA’s repository:

```bash
apt-get update
```

Install the CUDA Toolkit version 12.6 using:

```bash
apt-get -y install cuda-toolkit-12-6
```

This command downloads and installs the necessary files, including the CUDA compiler, libraries, and tools.

## Step 5: Configure Environment Variables

To ensure the CUDA Toolkit functions seamlessly, you will need to update the system environment variables.

Append the CUDA binary directory to the PATH variable:

```bash
echo "export PATH=/usr/local/cuda-12.6/bin${PATH:+:${PATH}}" >> ~/.bashrc
```

Include the CUDA library directory in the LD_LIBRARY_PATH:

```bash
echo "export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> ~/.bashrc
```

Activate the updated environment variables:

```bash
source ~/.bashrc
```

By configuring these variables, the system knows where to find CUDA executables and libraries.

## Step 6: Verify the Installation

Verify the GPU driver installation using NVIDIA System Management Interface (SMI):

```bash
nvidia-smi
```

Output:

![](https://www.atlantic.net/wp-content/uploads/2024/11/p1.png)

Ensure the NVIDIA CUDA Compiler (NVCC) is installed:

```bash
nvcc --version
```

Output:

```bash
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Tue_Oct_29_23:50:19_PDT_2024
Cuda compilation tools, release 12.6, V12.6.85
Build cuda_12.6.r12.6/compiler.35059454_0
```

## Step 7: Test CUDA Installation with Sample Programs

Download sample CUDA programs for testing the installation.

```bash
git clone https://github.com/NVIDIA/cuda-samples.git
```

Switch to the directory containing the deviceQuery sample:

```bash
cd cuda-samples/Samples/1_Utilities/deviceQuery
```

Build the deviceQuery program:

```bash
make
```

Execute the deviceQuery program to test CUDA functionality:

```bash
./deviceQuery
```

If the program runs successfully, your CUDA installation is complete.

![](https://www.atlantic.net/wp-content/uploads/2024/11/p2.png)

## Conclusion

Installing the NVIDIA CUDA Toolkit on an Atlantic.Net GPU server enables you to harness the power of GPU computing for complex applications. With this guide, you’ve verified your GPU compatibility, installed the CUDA Toolkit, configured environment variables, and tested the setup with sample programs. You’re now ready to develop and run CUDA-accelerated applications. Dive into [**Atlantic.Net’s GPU server hosting**](https://www.atlantic.net/gpu-server-hosting/) options and explore the possibilities CUDA offers!
