In this post we will explain how to prepare Machine Learning / Deep Learning / Reinforcement Learning environment in OSX / MacOS.
You can also have a look at version for Ubuntu - HERE
Of course this is only one of the ways to do it - so feel free to experiment.
It consists of :
First it is needed to install Anaconda - python virtual environment management and IDE.
This project has great documentation and you can find all the information HERE
So first download (from HERE) package for python version 3.7 and execute it.
Once installed we can create our first environment:
conda create -n py37 python=3.7
where py37 is the name of environment (you can choose anything you like of course) and important here is to specify python version (in this case 3.7).
We chose this specific version on purpose because OpenAI - as specified on their website - started to support also newest version of python.
After creating environment its time to activate it:
conda activate py37
Note! Rest of steps should be executed in activated environment.
And just in case we can check if there are packages to be updated:
conda update --all
Next step is to install Pytorch.
Important to note is that Pytorch stable version 1.6 has been released.
In order to install it - we go to their website where we can find clear instructions. You just need to specify options that you want… in my case:
So final command is:
conda install pytorch torchvision -c pytorch
So now it’s time to install OpenAI gym. This is bit tricky step so we need to be careful.
First as we will be using pip - lets make sure it is in latest version possible (also upgrading 2 other packages)
pip install pip --upgrade
And then, following instruction on their github page…
Before gym installation, we need to deal with its dependency - mujoco-py..
git clone https://github.com/openai/mujoco-py
pip install -e ./mujoco-py/
And now we’re ready to do gym installation!
pip install 'gym[all]'
Additionally if you want record videos in gym it is good idea to install ffmpeg via brew (and uninstall - if you have it - from conda)
conda uninstall ffmpeg
brew install ffmpeg
In order to use our code we will also need:
pip install matplotlib
So now - finally! - we can verify if everything is OK.
While installing Anaconda (in one first steps) we also installed Spyder - IDE for python. Of course use your favourite one but here in case of Spyder (executed via Anaconda-Navigator)…
we need to make sure that we chose proper environment (of course with the name as created before)
then execute it…
And now we can verify if everything works fine
If we have no errors on above steps - it means we’re OK and we’ve successfully installed our environment!
Depending on your requirements and (or) needs you probably might be interested in installing Tensorflow as well.
pip install tensorflow
And to verify:
python -c 'import tensorflow as tf; print(tf.__version__)'