# Deploy PyTorch on NeevCloud GPU and Run Experiments in Jupyter Notebook

Let's talk about the problem first: what happens if you run PyTorch code on Jupyter locally?

By default, PyTorch uses the CPU instead of a GPU unless you have a properly configured GPU setup. CPUs are not optimized for heavy parallel computations required in deep learning, so training or even inference can become very slow.

Most laptops don't have high-performance GPUs, and even if they do, setting up CUDA, cuDNN, and compatible PyTorch versions can be complex and time-consuming. This often causes dependency issues, version conflicts, or system limitations.

As a result:

* Model training becomes slow
* Large models may not run due to memory limits
* Performance testing can be inaccurate
* System resources get heavily consumed

This is where **NeevCloud** becomes important. By connecting NeevCloud GPU instance to Jupyter Notebook, you can write and run PyTorch code locally while performing heavy computations on a high-performance NeevCloud GPU.

In this guide, we will walk you through deploying a PyTorch template on NeevCloud, setting up the environment, and running a matrix multiplication to verify GPU usage.

***

### Step 1: Log in to NeevCloud Dashboard

1. Open your browser and go to [NeevCloud Console](https://console.ai.neevcloud.com/).
2. Enter your credentials to log in.
3. Once logged in, navigate to the **GPU AI Service→ "One Click Deploy"**.

***

### Step 2: Deploy PyTorch AI Template

1. **Select GPU (eg. NVIDIA A30)** Choose the GPU instance you want to deploy for your PyTorch workload.
2. **Configure Deployment**
   * **Name:** Auto-generated (e.g., neev-gpu-177). You can leave it as is or edit if needed.
   * **Template:** Select PyTorch Ubuntu 24.04
   * **Instance Pricing:** Choose On-Demand.
   * **Networking:** Default settings are sufficient
   * **SSH Access:** Enable and add your SSH key
3. **Configure Storage** Select Ephemeral Storage
4. **Pricing Check** Before launching, review the Pricing Summary. This helps avoid unexpected charges
5. **Launch** Click Deploy GPU and wait for the instance to show Running status

***

### Step 3: Optional – Verify GPU via SSH

Before verifying the GPU, first:

1. Select the recently deployed PyTorch instance from the NeevCloud Dashboard.
2. Open the Detail View page to see the deployment details.
3. From the Detail View page:
4. Copy the provided SSH command.

It will look similar to:

```
ssh <username>@<public-ip>
```

Open your terminal and paste the copied SSH command to connect to the instance.

After connecting, run:

```
nvidia-smi
```

You should see:

* GPU model
* Driver version
* CUDA version
* Memory usage

This confirms that the GPU and drivers are properly configured and working.

***

### Step 4: Access Jupyter Notebook on NeevCloud

1. Go to the Detail View page of the recently deployed PyTorch Instance and click **"Open in Browser"**.
2. The Jupyter Notebook will open in a new browser tab.
3. Enter the default password.

***

### Step 5: Create a New Notebook

1. Click **Python3 (ipykernel)**.
2. A new notebook will open and be ready for code execution.

***

### Step 6: Run PyTorch GPU Matrix Multiplication

Paste the following code into a cell:

```python
import torch
# Use GPU if available
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
# Create two random matrices
A = torch.randn(3, 3, device=device)
B = torch.randn(3, 3, device=device)
# Matrix multiplication
C = torch.matmul(A, B)
print("Matrix A:\n", A)
print("Matrix B:\n", B)
print("Result C:\n", C)
print("Device used:", C.device)
```

Press **Run**.

***

### Step 7: Verify Output

You should see something like:

```
Matrix A:
 tensor([[-0.4396,  0.4363,  1.2653],
        [ 0.2501,  0.7617,  0.3241],
        [ 0.3396, -0.5723, -0.2541]], device='cuda:0')
Matrix B:
 tensor([[ 0.0505, -0.6820, -1.6618],
        [ 0.3446,  0.2617,  0.9328],
        [ 0.9151,  0.7017, -0.6861]], device='cuda:0')
Result C:
 tensor([[ 1.2860,  1.3018,  0.2694],
        [ 0.5717,  0.2562,  0.0726],
        [-0.4126, -0.5597, -0.9240]], device='cuda:0')
Device used: cuda:0
```

If the device shows cuda:0, it confirms that the computation is running on the GPU successfully.

***

### Step 8: Cleanup – Delete GPU Instance

To avoid billing charges:

1. Go to **GPU AI Service**
2. Select the running GPU instance
3. Click **Delete Instance**
4. Confirm the deletion

This safely deletes the instance and stops billing.

***

### Conclusion

* PyTorch GPU template on NeevCloud was successfully deployed.
* Jupyter Notebook worked as expected.
* GPU acceleration confirmed via matrix multiplication.
* The environment is ready for AI/ML workloads.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ai.neevcloud.com/tutorials/deploy-pytorch-neevcloud-gpu-jupyter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
