Python in CSIL
There are many ways to edit, debug and run your Python code.
This page describes how to program and utilize Python in CSIL.
warning: this page is under construction. Your comments are welcome. (April 2025)
Python 3 is available on all CSIL workstations and CPU servers, including Windows and Ubuntu Linux.
If you believe certain 3rd party packages shall be added to these systems, please chat with the course instructor so an official request can be submitted to the helpdesk for evaluation.
Windows:
Windows 11 does not come with Python by default; it has been installed by the helpdesk on to all CSIL Windows workstations. A few highly recommended 3rd part packages have been added as well.
Please note: the exact version of Python on CSIL Windows most likely is different than on CSIL Ubuntu.
We recommend only utilizing the existing Python instance and tools/packages on CSIL Windows workstations. If you need a customized Python environment, please use CSIL Ubuntu workstations.
Ubuntu:
The Ubuntu 22.04 LTS (Jammy Jellyfish) running in CSIL comes with Python 3 by default.
Ubuntu 22 includes the built-in venv Python module. This venv module is used to create virtual environments - the virtual environments allow users to manage project-specific dependencies without affecting the system-wide Python installation.
Program Python using VSCode SSH into a CSIL Linux system
On your own laptop, you may edit your Python code using VSCode, while debugging the code on a CSIL Linux system for best compatibility.
Basically, use a Remote Python Interpreter over SSH into a CSIL Linux system.
For detailed instructions, please follow this guide (part of the Visual Studio Code online documentation).
Jumpstart
To utilize PyTorch, please use Python virtual environment on a CSIL Linux workstation.
For best consistent user experience, please configure such virtual environment on network scratch space. On a CSIL workstation, which is:
/usr/shared/CMPT/scratch/your_sfu_computing_id
- where your_sfu_computing_id is your SFU Computing ID.
Preparations (one-time):
Initialize a Python virtual environment by following the step 1 to 6.
Using the virtual environment:
When the suitable virtual environment is configured properly,
please follow the step 1, 3 & 5 every single time while you use this virtual environment for PyTorch;
when you finish up for the day, proceed with step 6.
Please be sure to use the same virtual environment.
step 1: get into CSIL personal network scratch space
login to a CSIL Linux workstation.
open a terminal and run:
cd /usr/shared/CMPT/scratch/your_sfu_computing_id
Please do not use any CSIL CPU server for PyTorch due to lack of hardware resource.
Warning: the CSIL network scratch space may get cleaned/wiped without advanced notice. Please be sure you have all your codes and data on your SFU Home.
step 2: create a virtual environment in current working folder
run:
python3 -m venv pytorch_venv
This command creates a virtual environment pytorch_venv in: /usr/shared/CMPT/scratch/your_sfu_computing_id
Remember: please always use this newly created virtual environment for the future. Please be sure to replace the pytorch_venv with your own preference.
step 3: activate the new virtual environment
run:
source pytorch_venv/bin/activate
The prompt changes, indicating now the virtual environment is in effect.
Remember: please always use the specific virtual environment.
step 4: install packages like PyTorch - as needed
to install PyTorch, run:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
In addition, you can load other 3rd party tools into this virtual environment.
step 5: use the new virtual environment
now, you can start coding Python with 3rd party tools like PyTorch in this virtual environment.
Please be sure copy the source code back to your SFU Home. Any contents on the scratch may get deleted without advanced warning/notice.
step 6: deactivate the virtual environment
when you are finishing up with the virtual environment, please copy your source code back to your SFU Home, then run:
deactivate
to be added.
Having comments, suggestions, inquiries and more questions? Contact us!
Please click here and use the best practices to get assistance from helpdesk.
Last updated @ 2025.04.16