Predictive RNNs
There are some extra steps in managing the requirements needed for the Predictive RNN project. This guide should help you get everything set up on Misha.
- Ensure you have an account on Misha, and log on. Make sure to allocate an interactive session (e.g.
salloc -t 2:00:00)!- Make sure you've also set up SSH cloning from the cluster, because you'll need to clone repositories into your storage. We're using SSH clone links from here out.
- See the page on HPCs for more information on this.
- Clone the
pRNNrepository into yourprojectfolder (git clone git@github.com:LevensteinLab/pRNN.git). - In your
HOMEdirectory (accessible by typingcd ~):- Make a folder for the virtual enviroment
mkdir venvs. - Clone Dan's fork of gym-minigrid (
git clone git@github.com:dlevenstein/gym-minigrid.git gym-minigrid-dan-fork).
- Make a folder for the virtual enviroment
- Create a conda environment with Python 3.9.
- Misha doesn't come with Python 3.9 out of the box, and we need this version for later dependencies.
- Type
module load minicondato ensure conda is loaded for use. - Run
conda create -n base39 python=3.9to make an environment calledbase39with python 3.9 installed. - Activate it (
conda activate base39).
- Make the
PredictiveReplayenvironment. This is done by runningmake_venv.sh, which is in the pRNN repo.- First comment out/change the following lines. This will ensure that the correct environments remain active.
module --force purgemodule load python/3.9virtualenv $VENV_DIRchanged tovirtualenv -p ~/.conda/envs/base39/bin/python $VENV_DIR(this ensures we're making the virtualenv with python 3.9)- Add
pip install virtualenvbefore the line in step 3 (line 18). - In line 49, change
#pip3 install gym-minigridtopip3 install -e ../../gym-minigrid-dan-fork(this ensure we're using Dan's forked version)
- Run
bash make_venv.shto create the environment.
- First comment out/change the following lines. This will ensure that the correct environments remain active.
- Load the environment. This is done by loading
load_venv.sh- Comment out the following lines again. This will prevent the underlying conda environment from being purged.
module --force purgemodule load python/3.9
- Run
bash load_venv.sh
- Comment out the following lines again. This will prevent the underlying conda environment from being purged.
- Activate the
venvenvironment. Runsource ~/venvs/PredictiveReplay_39/bin/activate. by now you should have two parenthesized environment names by each terminal prompt, like this(PredictiveReplay_39) (base39) [yourNetID@blahblah.misha]$. - Double check that
gym-minigridis installed correctly.- Run
pip list | grep minigrid. - If nothing shows up, it didn't install correctly. Run
cd ~/gym-minigrid-dan-fork, thenpip3 install -e .to install it into the environment.
- Run
- In your terminal (with both environments activated), run:
pip install "pip<24.1"pip install setuptools==59.5.0 wheel==0.37.0pip3 install gym==0.21.0 --no-binary :all:
- Rerun
bash make_venv.shthenbash load_venv.sh.- Sidebar from Viggy: To be completely honest, I have no idea why steps 9 & 10 work. I spent many hours trying to fix a random numpy error that pops up in the
tutorial.ipynb, but doing steps 9 and 10 fixes it, despite not reinstalling a different version of numpy. My hypothesis is that the downgraded version ofpip,setuptools, andwheelhelp us install this version ofgym, and when we rerunmake_venv.sh, we can reinstall the correct version of numpy (1.22.4instead of1.26.xthat it likes to do). It could be an issue with the order in which we install the packages at first. If you continue to have issues, try steps 9 and 10 again, and "turning [your kernel] on and off again". Or ask me, and we can figure it out. One day, I will figure out how to do this with fewer steps.
- Sidebar from Viggy: To be completely honest, I have no idea why steps 9 & 10 work. I spent many hours trying to fix a random numpy error that pops up in the
- Finally, make sure that the jupyter notebook kernel can recognize this environment.
- Run
pip install ipykernel(this will install it inside both environments). - Run
ipython kernel install --user --name=prnn-kernel. To allow jupyter notebooks to pick it up. - If you run
jupyter kernelspec list, you should seeprnn-kernelas an option. - You may need to restart your VSCode or kernel here.
- Run
- You should be able to run
tutorial.ipynbnow. This contains a single run setting up some environments.- You may get a
SyntaxError. This is because there's a small typo to fix. If you go to line 62 inprnn > utils > Shell.py, you may see an extra):. Delete that.
- You may get a