Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
deep_learning_miniconda_project [2017/03/10 21:53] – csteel | deep_learning_miniconda_project [2018/03/27 16:26] (current) – removed csteel | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== deep_learning_miniconda_project ====== | ||
- | |||
- | # file: Setting up virtual environments using .md | ||
- | |||
- | ===== References ===== | ||
- | |||
- | - [[ http:// | ||
- | - [[http:// | ||
- | |||
- | ===== Description ===== | ||
- | |||
- | The Miniconda installer installs | ||
- | |||
- | ====== Benefits ====== | ||
- | |||
- | - You can easily create, modify, activate and deactivate mulitiple custom Python environments. | ||
- | - You can create and run virtual Python | ||
- | - Each Python environement can be customized as you wish. | ||
- | |||
- | ====== Keep in mind ====== | ||
- | |||
- | It is easy to accidentally customize the Python environment that the miniconda installer installs for you and you probably do not want to do this. | ||
- | |||
- | Create a new, hosted, Python (virtual) environment for each of your project(s). This way your host Python installation, | ||
- | |||
- | ====== Requirements ====== | ||
- | |||
- | The user on the system must have sudo access to the following commands: | ||
- | |||
- | |||
- | - apt-get update or apt update | ||
- | |||
- | - apt-get install or apt install | ||
- | |||
- | ====== Options ====== | ||
- | |||
- | The checksums comparison in this document makes use of html2text | ||
- | |||
- | sudo apt update | ||
- | sudo apt install html2text | ||
- | |||
- | ====== Install miniconda ====== | ||
- | |||
- | ===== Is miniconda already installed? ===== | ||
- | |||
- | |||
- | conda --version | ||
- | |||
- | ===== Target Workstation ===== | ||
- | |||
- | mkdir -p ~/ | ||
- | |||
- | cd ~/ | ||
- | |||
- | ===== Download and verify ===== | ||
- | |||
- | wget https:// | ||
- | |||
- | chmod +x Miniconda2-4.2.12-Linux-x86_64.sh | ||
- | |||
- | ====== checksums ====== | ||
- | |||
- | ===== Download checksums ===== | ||
- | |||
- | wget https:// | ||
- | |||
- | ===== Convert to text file ====== | ||
- | |||
- | html2text -width 500 checksums.html > md5sums | ||
- | |||
- | ===== Compare checksums===== | ||
- | |||
- | md5sum Miniconda2-4.2.12-Linux-x86_64.sh | ||
- | |||
- | cat md5sums | grep Miniconda2-4.2.12-Linux-x86_64.sh | ||
- | |||
- | ====== Installation ====== | ||
- | |||
- | bash Miniconda2-4.2.12-Linux-x86_64.sh -b | ||
- | |||
- | ====== Add to ~/.bashrc ====== | ||
- | |||
- | nano ~/.bashrc | ||
- | |||
- | Content example: | ||
- | |||
- | # BEGIN ANSIBLE MANAGED BLOCK | ||
- | # | ||
- | # added to / | ||
- | # installer (and other versions?) usually add to a | ||
- | # users home directory. | ||
- | # set PATH to include ' | ||
- | # | ||
- | if [ -d PATH=" | ||
- | PATH=" | ||
- | fi | ||
- | # END ANSIBLE MANAGED BLOCK | ||
- | |||
- | ===== Manually export path ===== | ||
- | |||
- | This way we can run conda without restarting our terminal | ||
- | |||
- | export PATH=" | ||
- | |||
- | ====== test ====== | ||
- | |||
- | ===== Version check ===== | ||
- | |||
- | conda --version | ||
- | |||
- | ====== List current conda stuff ====== | ||
- | |||
- | conda list | ||
- | |||
- | ===== Update conda ===== | ||
- | |||
- | conda update conda | ||
- | |||
- | ===== Create and activate a virtual python environment ===== | ||
- | |||
- | Use the conda create command, followed by any name you wish to call it: | ||
- | |||
- | conda create --name deep python=2 | ||
- | |||
- | === output example === | ||
- | |||
- | Might be add source commands to acemenu and / or .bash_aliases | ||
- | |||
- | # | ||
- | # To activate this environment, | ||
- | # > source activate deep | ||
- | # | ||
- | # To deactivate this environment, | ||
- | # > source deactivate deep | ||
- | # | ||
- | |||
- | === Activate the environment === | ||
- | |||
- | If you run which python before activating your new Python environment you will see that the Python environment that ships with miniconda is the active Python at the moment: | ||
- | |||
- | which python | ||
- | |||
- | Output example: | ||
- | |||
- | / | ||
- | |||
- | Activate your new Python environment: | ||
- | |||
- | source activate deep | ||
- | |||
- | Run which python again an you whould see some thing like this: | ||
- | |||
- | / | ||
- | |||
- | Notice your prompt | ||
- | |||
- | When you activate a conda created Python environement the name you gave the environment prepended to your command prompt. In this example you will see that the prompt now begins with (deep) telling us that the custom python 2 environment we created earlier called deep is now the active Python for our user. | ||
- | |||
- | (deep) csteel@ace-ws-30: | ||
- | |||
- | Install some stuff | ||
- | |||
- | Now we are going to install our pip packages to our custom virtual python environment. Notice that we do not need to use sudo or the root user as this installation takes place in our home directory. | ||
- | |||
- | Deep project learning example: | ||
- | |||
- | pip install numpy matplotlib tensorflow | ||
- | |||
- | Create another custom Python environment | ||
- | |||
- | Here we create a second Python enviroment as an example. In this case we create a Python 3 environment called data. | ||
- | |||
- | conda create --name data python=3 | ||
- | |||
- | IMPORTANT: Notice that the Python environment deep is still active. If you install anything Pythonic now it would be installed to the deep Python environment. You will want to deactivate deep and then activate data before you can install to your Python 3 environment: | ||
- | |||
- | source deactivate deep | ||
- | |||
- | you will notice that the (deep) command prompt prefix is no longer visible. Next we will activate our new Python 3 environment: | ||
- | |||
- | source activate data | ||
- | |||
- | Now you are ready to install to the deep Python 3 environment. Note that you can switch environments without deactivating as activating a new environment automatically deactivates the currently active environment. In other words we could have just run source activate data . | ||
- | |||
- | Install your stuff | ||
- | |||
- | pip install ipython notebook | ||
- | |||
- | Which pythons are available | ||
- | |||
- | You set up Python environments with (almost?) any version of Python available. Have a look: | ||
- | |||
- | conda search python | ||
- | |||
- | List your current conda environments: | ||
- | |||
- | conda info --envs | ||
- | |||
- | output example: | ||
- | |||
- | # conda environments: | ||
- | # | ||
- | data * / | ||
- | deep / | ||
- | root / | ||
- | |||
- | Hint: | ||
- | |||
- | Notice the environment named root. This is the Python environment which hosts the conda command. You will probably don't want to install to your root Python so ensure that you make one of your custom Pythons is active before installing programs. | ||
- | |||
- | Removing environments | ||
- | |||
- | You can probably just delete any non-root Python environments you have created using the conda command like this: | ||
- | |||
- | rm -R / | ||
- | |||
- | but you probably want to check out the manual first eh? | ||
- | |||
- | Completely uninstalling miniconda | ||
- | |||
- | If you destory your Miniconda installation you can get rid of it very easily. Keep in mind that this will also delete any associated environments as well. | ||
- | |||
- | rm -rf ~/miniconda | ||
- | rm -rf ~/.condarc ~/.conda ~/ | ||
- | |||
- | remove PATH environment variable | ||
- | |||
- | edit ~/ | ||
- | |||
- | |||