pc_guidelines
Guidelines for using IvLabs PC. General instructions for maintaining and using any PC/laptop while using Ubuntu for Robotics/DL/RL research.
Last updated Nov 20, 2024
21
Stars
3
Forks
0
Issues
0
Stars/day
Attention Score
6
Language breakdown
No language data available.
▸ Files
click to expand
README
IvLabs PC and GPUs Usage Guidelines
_ | | | | | | | | | | | | __ | \ \ / / | / ' | ' \/ __| | |\ V /| || (| | |) \ \ \/\/ \/\,|./|/Welcome to the IvLabs PC. If you are on this page, chances are you have just been given access to the PC. Follow the rules for using this PC at Lab New PC instructions. Before using any GPU, you must book it in Lab new PC usage record. If you don't understand how to use things, contact the admin on the Discord channel #pc.
GPUs and other resources
- Keep usage of resources under control. For RAM and cores usage :
htopand for GPU usage :nvidia-smiorgpustat - After running your code (in case it is not stable), make sure that resources being used are under control (using above commands).
- To use a GPU, you must first book it at this google sheet provided, you will find some rules on how to do it in the spreadsheet. If you have any questions, please ask!
- In case you have to login using the monitor in lab, then remember to log out before leaving. This is necessary since logging in at the monitor will take up GPU memory which is not released even when the monitor is switched off.
- Use at most one GPU at a time. In case you need more, use the Discord #gpus channel to ask for permission and coordinate with the other users.
torch.cuda.set_device(id) to set the proper GPU. Replace id with 0 for GPU0 and so on.
- After completing your task make sure you release the GPU memory (if not done automatically). Use
nvidia-smito look at running processes and kill them usingkill <pid>. - To determine the owner of process
<pid>, useps -o user= -p <pid>to find the username of the owner. If GPU is not booked, use the #gpus channel on Discord to coordinate with the user or request the admin to kill the process. If unbooked GPU user does not respond quickly, then admin must kill the process.
How to setup your enviroment
- You must use conda to create an enviroment if you have custom dependencies for your project. DO NOT install conflicting packages in the base enviroment.
- Useful conda commands are listed below
conda create -n <nameofyour_enviroment>
- Enviroment with custom Python version: conda create -n <nameofyourenviroment> python=X.X where X.X represents the Python version you want to install. For example, the command for creating an enviroment with Python 3.5 would look like: conda create -n <nameofyourenviroment> python=3.5
- To install custom packages while creating your envrioment you can just list them out like this:
conda create -n <nameofyour_enviroment> <package1> <package2>
e.g. for creating enviroment with pip and sklearn packages the command would be: conda create -n <nameofyour_enviroment> pip sklearn Note: You can install pip as a conda package and then use it to install other packages as well
- Make sure you are within your own environment and then you can use conda to install packages: conda install <packagename>, if the package is on custom channel use: conda install -c <channelname> <package_name>
- For more information on how to use conda please refer to the conda official documentation.
Writing code over ssh
- Jupyter Lab / Notebook :
jupyter-lab --port=<allocated_port> --no-browser after logging into your account.
- In a local terminal, use ssh -f -N -L localhost:<localport>:localhost:<allocatedport> username@ipaddress to forward the allocatedport to your local_port.
- Note that localport and allocatedport are 4-digit numbers. Also, if either of the ports is already in use, the above command may fail.
- Open the browser in your local PC and type URL localhost:<local_port>.
- Example: Suppose you want to start jupyter-lab with port 6767 on the remote PC, then use jupyter-lab --port=6767 --no-browser. This will start a Jupyter Lab at port 6767 (this is the allocatedport). Now, suppose you want to access it in your local PC at port 8988 (this is the localport), then use ssh -f -N -L localhost:8988:localhost:6767 username@ip_address. Note that this is called port forwarding (forwarding port from remote to local PC). Then, in your local browser, use the URL localhost:8988.
- Note: Same commands apply for Jupyter Notebook. Just replace jupyter-lab by jupyter-notebook.
- For installing Anaconda enviroments in Jupyter, use the following commands
source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
for more info refer link
- Visual Studio Code :
- PyCharm or Atom or other editors :
- Vim / Nano :
vim and nano are terminal-based text editors which can also be used for quick access.
Using GUI applications over ssh with X11 forwarding
- The requirements for the server side are already setup by the admin.
- On your own Ubuntu machine, while logging in, use
ssh -X username@ip_address. - To make X11 forwarding default in your machine, add
ForwardX11 yesin the~/.ssh/configfile in your local machine. - Then, any GUI application can be started on the remote server (using the usual commands) and the display will be shown on your local machine.
Using ROS and ROS based applications
- ROS has already been installed system-wide. However, ROS environment variables will not be sourced by default in your bash terminals (since
source /opt/ros/kinetic/setup.bashhasn't been added to the.bashrcfile of the root user). - Thus, to use ROS, you must do
source /opt/ros/kinetic/setup.bashin each terminal that you wish to use for ROS related commands. To make it default to your user (NOT the root user), you may add this command to your user's.bashrcfile (this file is present in your home folder. If you're unsure, you can contact the admin on #gpus channel on Discord). - Note that there is no need to use the monitor in the lab for ROS based applications. You can do your work through ssh, and follow the X11 forwarding instructions above to get GUI applications working through ssh.
- WARNING: If you add the source command to your
.bashrcfile, then you risk conflicts between your dependencies and dependencies in yourcondaor other environments (if any). So, if you face conflicts in (say) OpenCV (this is the most common conflict), then be sure to check your.bashrcfile. - WARNING: Your simulations may lag when any training is going on (since CPU is also used during training). So, check if training is going on using
watch nvidia-smiand coordinate with other users on the #gpus channel on Discord.
.bashrc file. It will create conflicts for other users' environments who don't use ROS.
How to launch experiments
- Use
tmuxto keep the session active even when you are disconnected from the server.
- Run the program or start the Jupyter Notebook / Lab within the tmux session.
- Use the
watch nvidia-smiorgpustat --watchcommand to monitor GPU usage. - Use
htopto keep resources under control. - If other users are already using for training or running simulations or other tasks, then coordinate with them on the #pc channel on Discord.
🔗 More in this category