Home >Backend Development >Python Tutorial >Set up Anaconda on Ubuntu in Minutes: Simplify Your AI Workflow
When it comes to data science, machine learning, or managing AI projects, having the right tools can make all the difference. Anaconda is a powerful library that simplifies managing packages, dependencies, and environments for Python-based projects. If you're working actively with the development of AI models or a beginner looking forward to entering the data science industry, installing Anaconda sets you up with everything you need to hit the ground running.
This guide will show you the step-by-step process for installing Anaconda on Ubuntu using the installer script and initializing the "conda" environment to start building with it.
A Virtual Machine (such as the ones provided by NodeShift) with at least:
Ubuntu 22.04 VM
Note: The prerequisites for this are highly variable across use cases. For a large-scale deployment, one could use a high-end configuration.
For this tutorial, we'll use a CPU-powered Virtual Machine by NodeShift, which provides high-compute Virtual Machines at a very affordable cost on a scale that meets GDPR, SOC2, and ISO27001 requirements. It also offers an intuitive and user-friendly interface, making it easier for beginners to get started with Cloud deployments. However, feel free to use any cloud provider you choose and follow the same steps for the rest of the tutorial.
Visit app.nodeshift.com and create an account by filling in basic details, or continue signing up with your Google/GitHub account.
If you already have an account, login straight to your dashboard.
After accessing your account, you should see a dashboard (see image), now:
1) Navigate to the menu on the left side.
2) Click on the Compute Nodes option.
3) Click on Start to start creating your very first compute node.
These Compute nodes are CPU-powered virtual machines by NodeShift. These nodes are highly customizable and let you control different environmental configurations, such as vCPUs, RAM, and storage, according to your needs.
1) The first option you see is the Reliability dropdown. This option lets you choose the uptime guarantee level you seek for your VM (e.g., 99.9%).
2) Next, select a geographical region from the Region dropdown where you want to launch your VM (e.g., United States).
3) Most importantly, select the correct specifications for your VM according to your workload requirements by sliding the bars for each option.
1) After selecting your required configuration options, you'll see the available VMs in your region and as per (or very close to) your configuration. In our case, we'll choose a '2vCPUs/4GB/80GB SSD' as the closest match to the "Prerequisites".
2) Next, you'll need to choose an image for your Virtual Machine. For the scope of this tutorial, we'll select Ubuntu, as we will install Anaconda on Ubuntu.
1) Two billing cycle options are available: Hourly, ideal for short-term usage, offering pay-as-you-go flexibility, and Monthly for long-term projects with a consistent usage rate and potentially lower cost.
2) Next, you'll need to select an authentication method. Two methods are available: Password and SSH Key. We recommend using SSH keys, as they are a more secure option. To create one, head over to our official documentation.
Finally, you can also add a VPC (Virtual Private Cloud), which provides an isolated section to launch your cloud resources (Virtual machine, storage, etc.) in a secure, private environment. We're keeping this option as the default for now, but feel free to create a VPC according to your needs.
Also, you can deploy multiple nodes at once by clicking in the Quantity option.
That's it! You are now ready to deploy the node. Finalize the configuration summary; if it looks good, go ahead and click Create to deploy the node.
As soon as you create the node, it will be deployed in a few seconds or a minute. Once deployed, you will see a status Running in green, meaning that our Compute node is ready to use!
Once your node shows this status, follow the below steps to connect to the running VM via SSH:
1) Open your terminal and run the below SSH command:
(replace root with your username and paste the IP of your VM in place of ip after copying it from the dashboard)
ssh root@ip
2) In some cases, your terminal may take your consent before connecting. Enter ‘yes’.
3) A prompt will request a password. Type the SSH password, and you should be connected.
Output:
First, we need to download the Anaconda installer that will further help us to install Anaconda in the system. Use the following command to download the installer:
1) Update the system package source-list and upgrade the softwares.
apt update && apt upgrade -y
Output:
2) Add a non-administrative user
To avoid any accidental changes to the entire system, we'll create a non-root or non-administrative user, and do all the installations with that user account.
For the demonstration purposes, we'll create a user named "demo" and log in as the demo user:
(replace demo with your preferred username)
adduser demo-user usermod -aG sudo demo-user su - demo-user
Output:
3) Navigate to tmp directory
Next, move to the tmp directory to isolate the installation from your working directory
ssh root@ip
4) Download the installer
Use the below command to download the installation script that will be used to install Anaconda and rename it to anaconda.sh
apt update && apt upgrade -y
Output:
Next, use the below command to get the checksum of the downloaded script.
adduser demo-user usermod -aG sudo demo-user su - demo-user
Output:
To ensure that the downloaded script is not corrupted, match the checksum you got in the above output with the checksums provided by the official Anaconda website.
Just like above, if you're able to find your checksum in the list, then the script file is safe to use and proceed with. If not, repeat the above steps to download the script again.
After verifying the script, proceed with Anaconda installation.
1) Run the script using the below command to start the installation:
cd /tmp
Output:
Note: The above command performs a silent installation (non-interactive), which means the installer assumes that you accept the "default" settings, such as the default location and license agreement; hence, it directly installs the package.
However, if you want to specify the location path, you may use the following command to perform the installation in interactive mode:
wget -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
2) Initialize Anaconda
If you installed the package in non-interactive mode or installed in interactive mode but entered NO when asked for auto-initialization, then use the following command to activate Anaconda:
sha256sum anaconda.sh
If downloaded in interactive mode and entered YES in the auto-initialization prompt, then it will get activated automatically after installation. Just refresh the bash file for changes to take effect:
bash anaconda.sh -b
3) Add Anaconda functions
bash anaconda.sh
Output:
then refresh the shell:
source <PATH_TO_CONDA>/bin/activate
4) Verify installation
Finally, let's confirm if the installation is complete and Ananconda is ready to use.
ssh root@ip
Output:
If you see this, it means the installation and initialization of Anaconda are successful. Now, whenever you open a new terminal, the base environment will initialize automatically, so you can start using conda functions directly. However, if you do not want this behavior and instead prefer activating the environment manually each time before using conda, use the below command to disable this:
apt update && apt upgrade -y
Now, every time you want to use conda, you should first activate the base environment using "conda activate", and then you are good to proceed with using conda.
Installing a powerful Python library like Anaconda is a crucial step for anyone looking to power up their data science or machine learning workflows. This guide walked you through downloading, installing, and activating Anaconda to get your environment ready for efficient development. By deploying our Ubuntu server on NodeShift, we unlocked additional benefits like optimized energy consumption, scalability, and enhanced performance customized to modern workloads. NodeShift's infrastructure ensures a smooth and reliable setup, making it the ideal choice for deploying resource-intensive tools like Anaconda in a sustainable and efficient manner.
For more information about NodeShift:
The above is the detailed content of Set up Anaconda on Ubuntu in Minutes: Simplify Your AI Workflow. For more information, please follow other related articles on the PHP Chinese website!