Skip to content
oshrout edited this page Feb 15, 2023 · 24 revisions

Init anaconda for a new user

/opt/anaconda3/bin/conda init

  • To use Anaconda add the following line to ".bashrc" file in your /home/user_name directory
    export PATH="/opt/anaconda3/bin:$PATH"

Specify the GPU number

If you are assigned a GPU number, you can use:

export CUDA_VISIBLE_DEVICES=1

This way, every program running in the current shell will see only that GPU number.

Or:

export CUDA_VISIBLE_DEVICES=0,1

For multiple gpus.

Specify the CPU number

taskset -c 0,5 python main.py

You can create a run_command.sh file for easy control (gpu num#5, and 16 THREADS):

#!/bin/bash
export CUDA_VISIBLE_DEVICES=5 
export OMP_NUM_THREADS=16
python main.py

Running Jupyter Notebook on a remote server

(From Notebook on a remote server)

Follow the following steps to use Jupyter Notebook launched from remote server.

  1. Launch Jupyter Notebook from remote server, selecting a port number for :
# Replace <PORT> with your selected port number
jupyter notebook --no-browser --port=<PORT>

For example, if you want to use port number 8080, you would run the following:

jupyter notebook --no-browser --port=8080

Or run the following command to launch with default port:

jupyter notebook --no-browser

Please note the port setting. You will need it in the next step.

  1. You can access the notebook from your remote machine over SSH by setting up a SSH tunnel. Run the following command from your local machine:
# Replace <PORT> with the port number you selected in the above step
# Replace <REMOTE_USER> with the remote server username
# Replace <REMOTE_HOST> with your remote server address
ssh -L 8080:localhost:<PORT> <REMOTE_USER>@<REMOTE_HOST>

The above command opens up a new SSH session in the terminal.

  1. Open a browser from your local machine and navigate to http://localhost:8080/, the Jupyter Notebook web interface. Replace 8080 with your port number used in step-1.

Mount server file system to your local machine


Kill all processes of a single GPU

Print all processes of GPU 2:

nvidia-smi -g 2 | awk '$5=="PID" {p=1} p {print $5}'

Kill all these processes:

kill $(nvidia-smi -g 2 | awk '$5=="PID" {p=1} p {print $5})