Setting Up VM for a Clean Workspace
If I am working on a project using TensorFlow, I create an environment with the appropriate version of TensorFlow and other libraries. That way, If I want to work on a project that requires a different version of TensorFlow or any of the other libraries, I can just create another environment. No clashes!
In the world of Machine Learning, we prototype code using Python. Python is mainly used in ML for a few reasons: readability, ease of use, and lots of packages. There are so many packages for linear algebra and other ML tools, so you don't have to reinvent the wheel. And these packages are already heavily optimized.
My favorite Data Science platform to use is Anaconda. In its rawest form, Anaconda is a Python and R distribution. It's one of the most popular platforms for ML and Data Science. Along with the languages, Anaconda comes with over a 100 packages, and more packages can be downloaded using conda. It also come with Spyder and Jupyter Notebook for writing code.
Let's fire up Ubuntu.
There are a few ways to download Anaconda. I will download it using command line.
Step 1 - Get the latest Version of Anaconda
First you need to go to the Anaconda website, and go to the Linux download. Right click on the download link and copy the link location from your host machine.You clipboard should have something very similar to this:
https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
Then go to your /tmp directory in your VM. Use the command:
curl -O https://repo.anaconda.com/archive/Anaconda3-5.3.0-Linux-x86_64.sh
to download the repo into your VM.
If you don't have the command curl, download it with
sudo apt install curl
Step 2: Make Sure Everything is Correct
You can make sure your download is safe with:
sha256sum Anaconda-5.3.0-Linux-x86_64.sh
Your output should look something like this:
Step 3: Install
Now, you can run this script to download:
bash Anaconda3-5.3.0-Linux-x86_64.sh
Make sure you're prompted to add Anaconda to your path. Only then will your computer know where to look when you want to run something from Anaconda.
You also have the choice to install VS code. That's for you to decide.
to let the changes take effect.
Try conda list again. If it doesn't work, you did something else wrong.
Your terminal should look like this:
Go through the installation process. You should be fine with accepting all the defaults, but if you want to change the download location, you can do it here.
Make sure you're prompted to add Anaconda to your path. Only then will your computer know where to look when you want to run something from Anaconda.
You also have the choice to install VS code. That's for you to decide.
Step 4: Activate
You can activate your install with this command:
source ~/.bashrc
Step 5: Test
Test your install with this command:
conda list
If the command doesn't work, it means that you didn't add Anaconda to your path properly. But don't worry, it's an easy fix.
First you need to find the download location of Anaconda and its bin folder. That's where the commands live. Now, you need to update your path (Use pwd while in the bin folder to get the full path).
Once you have the path to your bin folder, open or create a .bashrc file in your home directory (You can get to your home directory by typing "cd"). Once you open the file, scroll down to the bottom and add the path to bin.
You can use any editor you want to edit your files; I'm going to use vi. So to open a file in vi, use:
vi filename
Use the arrow keys to go to the bottom of the file and add the path. In vi, you have to hit the letter "i" for insert before you can type.
You file should look like this:
You file should look like this:
Once you're done editing the file, hit the escape key and type ":wq" to exit the file.
Restart your VM or use this command:
source ~/.bashrc
to let the changes take effect.
Try conda list again. If it doesn't work, you did something else wrong.
Step 6: Creating Environments
You can create an env with this command:
conda create --name py36 python=3.6
This creates an environment with python 3.6, but you can choose any version of python. You can create another env with a different version of python, and there won't be clashes. Everything is neat and clean.
I name my env "py36," but you can name it anything you want.
Activate your env with source activate py36. Anything downloaded in this env will only be in this env.
Once you are done, you leave the env with the command source deactivate
Once you are done, you leave the env with the command source deactivate
Now you know how to keep everything clean and organized for all projects. No version clashes!
Let's put this to work with our next project.
Sorry I took so long to write a post. I was driving a lot, and I had so much work to do for school and other projects. In the next post, we can dive into our first linear regression model.





Comments
Post a Comment