0% found this document useful (0 votes)
5 views

Lab 0 - Intro

Uploaded by

fydaemalinax
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Lab 0 - Intro

Uploaded by

fydaemalinax
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

October 3,

2024
Reinforcement Learning – Faraz Janan
Version 1.1

Lab Assignment 0: Introduction


We want to make sure that everybody is ready to go with content. Therefore, the
purpose of this introductory lab session is to ensure that you can log into the college
systems and setup and run Python as will be necessary for the rest of the lab
assignments and courseworks. Throughout this guide, we assume you will be running
on a Linux system in Computing (or use remote desktop to access one).

Running Python

There are a number of ways in which Python can be installed and run. Linux comes
with its own version of Python 3 installed: open a terminal window and run the
command python3. To exit Python commands, enter quit(). Linux comes with both a
Python 2 and Python 3 versions. We will be working in Python 3, using the pip package
manager.

Virtual Environments and Packages

We can enhance the base Python installation with whichever libraries we choose.
However, it is good practice to set up and run scripts in separate virtual environments
for projects that require different libraries and packages to avoid possible dependency
clashes.
Start by updating your package manager, run: python3 -m pip install --user --upgrade
pip. Create a virtual environment called rl by using the command python3 -m venv rl.
A directory rl will be created containing files relevant to this new virtual environment.
Next, activate the environ- ment by running the command source rl/bin/activate. You
should now see (rl) in front of your username in the terminal window. Now, any
modifications or package installations you carry out will be applied only to rl rather
than the base environment.
Install the numpy and matplotlib libraries by running pip install numpy matplotlib.
Once it has completed, run python3 and try to import numpy to check the installation
was successful.

Notebooks

The Jupyter package will allow you to run interactive notebooks in which you can run
Python code. Run pip install jupyter to install Jupyter. Once it is done, try to launch a
notebook by running
jupyter notebook. Check that you can import the numpy and matplotlib modules in your
notebook. You may have to run the command python3 -m ipykernel install --user --
name=rl to include the packages from your rl environment in the notebook. After you
do this, restart the jupyter notebook and after opening a new notebook you should see
the option to change to your virtual environment under the ‘Kernel’ menu options.
Later on in the course, you will be required to install other packages (mainly PyTorch
and OpenAI Gym), which you will be able to install similarly.
Another resource you may find useful in alternative to Jupyter notebooks are Colab
notebooks. This allows you to run code remotely and potentially use powerful GPUs.
Check the page
https://colab.research.google.com/ to investigate this alternative.

You might also like