Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Run a Jupyter notebook and keep your work

Run code on a GPU in a notebook, see what survives a stop, and copy your work somewhere safe before you delete the server.

Last updated November 21, 20263 min read
View as Markdown

You will run a notebook on a rented GPU and then learn which of your files survive, and how to copy them to a place you control. A server's disk is not a backup, so this part matters as much as the code.

1. Start a notebook server

If you did Your first GPU server, use that server. Otherwise open Deploy, pick a GPU with VRAM of 8 GB or more, select the Notebooks filter above the template cards, select PyTorch + JupyterLab and request the server. If you also select an SSH key on the configure step, you can copy files with scp later.

When the status is Running, open the server, select the Connect tab and select Open Jupyter.

2. Run something on the GPU

In JupyterLab, select Python 3 (ipykernel) under Notebook. Run this in the first cell:

import time
import torch

x = torch.randn(8192, 8192, device="cuda")
torch.cuda.synchronize()
start = time.time()
y = x @ x
torch.cuda.synchronize()
print(f"{time.time() - start:.4f} s on", torch.cuda.get_device_name(0))

It prints the time of one large matrix multiplication and the GPU name. Your number depends on the GPU. In a second cell, save a small result next to the notebook and list the folder:

torch.save(y[:4, :4].cpu(), "/workspace/sample.pt")
!ls -lh /workspace

You should see sample.pt in the list. Press Ctrl+S to save the notebook. The file browser on the left starts in /workspace, so your notebooks are saved there too. Right-click the notebook in the file browser and choose Rename to give it a better name.

3. Install what you need

In a cell, %pip install pandas adds a package. Packages are installed in the server's system, not in /workspace. A hard reboot keeps them, but Destroy and Recreate container erase everything on the server, /workspace included. Keep a requirements.txt with your notebooks off the server (on a volume or your own computer), copy it to a new server and run %pip install -r /workspace/requirements.txt.

4. See what survives a stop

  1. Open the server's page and select Stop, then Stop server.
  2. When it shows Stopped, select Start.
  3. Open the Connect tab and select Open Jupyter again. The address can change after a start.

Your notebook and sample.pt are still in the file browser. The disk is kept while the server is stopped. It is deleted when you destroy the server, and when the host's rental period ends. See Storage and data.

5. Keep your work

Do at least one of these before you destroy the server:

  • Download from the browser. In the file browser, right-click a file and choose Download. For a folder, make an archive in a cell first with !tar -czf /workspace/project.tar.gz -C /workspace my-project, then download that file.
  • Copy with scp. On your own computer, with PORT and HOST from the Connect tab:
scp -P PORT root@HOST:/workspace/project.tar.gz ./

More methods are compared in Moving data.

Anyone who has the access token can run code on your server, and the page is plain http. Do not share the address, and do not put secrets in the notebook.

When you are done: stop or delete

  • Stop ends the compute charge and keeps the disk, which is still charged. Use it for a break.
  • Destroy ends every charge and deletes the disk. Use it when your files are safe elsewhere. Open the server, go to Settings, select Destroy server and type the server name.

Next

Ready to try it?

Create a free account and add credit when you want to start a server. The smallest top-up is $10.

Create a free account

Was this helpful?

Still stuck? Contact us