How to Set Up a Machine Learning Environment with Conda and Pip-Tools

Automata Learning Lab · Beginner ·⚡ Algorithms & Data Structures ·4y ago

Key Takeaways

This video tutorial demonstrates how to set up a machine learning environment using conda and pip-tools, covering the creation of a conda environment, installation of dependencies, and management of dependencies using pip-tools and makefiles. The tutorial utilizes tools such as conda, pip, PyTorch, CUDA toolkit, and make to create a hybrid environment for machine learning development.

Full Transcript

what's up guys welcome back to the channel in this video we're going to learn how to set up a hybrid conda in pipto's environment for machine learning basic idea is to our objective today is to start from nothing and finish with a folder containing some basic machine learning code and the entire environment setup configured from start to finish so the first step is to create a con environment and we'll specify the python version now let's go ahead and we're going to create an environment so we'll go conduct create minus n and then the name of this environment is the setup ml f all right and i will specify a python version to uh python 3.7 all right so once we've done that say yes so the first step first step is that now the second step is to we're gonna now we'll activate our our environment perfect now that we have activated the environment we can go to step three which is to install the right cuda tool for our pi torch environment in this case i decided to do a machine learning example using pytorch but uh we it would work the same for tensorflow the only things that we will have to install different packages uh so that's what we're going to do we're going to install and now that we have instead of installing so now the third step is to install the right cuda tool for our pi torch environment now in this example i'm going to be using pytarch code but for tensorflow the the setup will be very similar the only thing that differs is the installation of the tensorflow packages and instead of the buy touch packages but in this case we're not going to install piper right now we're going to first install the cuda tool that i need so in my case i'm going to install the kuda toolkit 10.2 because it's the version that is compatible with my with my machine so that's what i'm going to do so that's what i'm going to do here so that's what i'm going to do here so i'm going to just go auto install the tool kit 10.2 perfect i'm installing cuda toolkit perfect now that i've done that step number four is to export the environment to an environment.yml file so we can do that with conda and export and then we're going to say from history so that it doesn't export a lot of things that are they're not we're going to say condyle of export from history so that we just export to this environment oml file uh what we have installed so far which is in this case the python version and the cuda toolkit and then we say in what environment file perfect now to check we can just come here and we we can look up our file and we can see here that we have in the environment.yml file the cuda toolkit and the python uh and the python version perfect perfect now we can go back to our terminal and go to step number five which is to create the requirements folder now we can go to step number five which is to create the requirements folder with the necessary dot in files now these dot m files are files that will create so that they can work with a tool we'll use which is called pip tools and this tool is amazing because it allows you to keep to it allows you to compile a automatically a requirement.txt file from a set of simple dependencies that will as humans will manually input and it can allow us to keep uh mutually compatible versions of packages in the development code and the production code and so that we don't have to take care of looking up dependencies for packages we want to install to make sure that we don't run into conflicts and issues with compatibility so what we're going to do now is we're just going to create a folder called requirements uh and now what we're going to do is we're going to create a folder called requirements and inside that folder we're gonna create a file called dev dot in and another file called prod dot in perfect uh the product in file will keep the dependencies for the actual uh production code let's call it the the main source code the stuff that's gonna go to deployment and the dev.m file is gonna is gonna have the development packages the packages that we are using to develop our source code and to develop our project all right so now that we have created this file and now what we're going to do is we're going to put the dependencies in these files so in this case i'm going to go to my m file and in here the first thing i'm going to do is since i want to do a project with pytorch the dependencies i'm going to need are torch porch vision numpy and pill and pillow right and in the dev now i can go to the dev dot in file let's say we wanted to add a visualization so we're going to put like wallet maplin for example right and we're going to we're going to put it right here and at the top of this that at the top of this dev dot m file we're going to put a command saying minus c prod dot txt what this is doing is constraining the development packages to the production packages to make sure they're mutually compatible this is a great way to make sure they're keeping everything consistent and this line is constraining the development now what i can do is instead of compiling and generating the uh corresponding dev.txt file and product text files now what i'll do is i will write a make file because i just don't want to do this once or right now but i want to have a make file so i can update things as i go automatically and as easily as possible inside this make file we'll have three basic commands we'll have a help command and that will print the make file commands that we have we'll have a conduct update command to update our environment and we'll have a pip tools command to install compile and sync our dependency requirements in both development and production environments it's important to note that so for our make file i already i have one set up so i will just copy from my example environment so copy the make file here and now i'm gonna show you what it looks like so this is the make file that we have the our uh so the first command here we're printing all the commands that we have inside this make file this is actually was taken from this stack overflow response so these the first three line the first line here is printing the make file commands now instead of going through this entire command since i didn't write it this was actually taken from the stack overflow answer i since i'm gonna leave a github repo that you can access and see the make file you can reveal this command for yourself but basically here we're printing all the commands inside the make file next we're gonna we're gonna set up uh we're going to set up conda update next we're going to set up the conda update command so the condell update command does two things uh the yeah the update command is two things first it uh it does an update to our environment right with the conda m update and um it has an update in our environment from the yml file that we have and then it prints out a warning so that we activate the environment that we created and the second command and the and the third command is the big tool command which compiles and installs the exact packages that we need from the files that we created in this case product in and dev.end right and finally it uses the pip sync command to install the dependencies from these two packages from these two requirements files uh from these true requirement files at the same time which is great because now we know that we're working with dependency packages that we can actually install the dependency packages from two different requirements files and they will work inside the same environment because of this awesome pip tools because of the awesome pictures package so these two super powerful commands really help us out it's important to note that what i'm reproducing here is an updated version of the lab setup from the full stack deep learning course which is one of the best practical deep learning courses out there to learn how to do machine learning for industry and they teach all the practical aspects of how to set up not only how to set up environments but how to develop code train do experiment tracking data management all that good stuff and i definitely recommend you check them out and i'll leave a link to the description to their course that's about it with the make file now we can follow up to uh step number seven which is to run make conda update so we can quickly uh let's uh just be pedagogical let's deactivate uh we'll deactivate our environment right and now we're going to run a make on that update so perfect and now we can activate our environment now this is just the uh this is just to be thorough with you know how we're setting this up uh perfect we can check on that environment.our file so that you can see it's looking good so perfect this is the environmental ml file and now we can run make pip tools and it will install all the packages in the dot m files and take care of any potential conflicts that might exist now we can do that with now we can do that with make tip tools and now we're installing all the necessary packages for this project so now what we can observe is that we should have the uh dependency files generated so as you can see here there's a file called text and that dot x has all the dependencies that we need and it was compiled automatically which is awesome and the same thing for production right and that's pretty much it this is how you set up uh properly and that's pretty much it that's how you set up properly a development uh and that's pretty much it that's how you set up a hybrid conda and pip tools environment to work in machine learning and make sure that the development code that you have is compatible with the stuff that you have in production so as you develop your application or your machine learning model or whatever you're always uh just updating uh these files with a simple uh make uh conda update and make pip tools commands and you're always uh you're always sure that you're developing and you're developing your environ your environment is consistent will be consistent across machines and a really nice feature of this is that by having these two files and using pip tools you can make sure that you know your project will work in machines that don't accept condo for example so thanks for watching and don't forget to like and subscribe and see you next time cheers

Original Description

In this tutorial, we will look at how to set up a development environment for machine learning using conda and pip-tools. The idea is to organize a robust and deterministic environment that works consistently by organizing the mutually compatible versions of the dependency packages into two requirement files, one for development and one for production. - Link to my Medium article: https://lucas-soares.medium.com/setting-up-an-environment-for-machine-learning-with-conda-pip-tools-9e163cb13b92 - Link to my Github repo: https://github.com/EnkrateiaLucca/setting_up_ml_env_conda_pip_tools - Follow me on Medium: https://lucas-soares.medium.com/ - Join Medium: https://lucas-soares.medium.com/membership - Twitter: https://twitter.com/LucasEnkrateia - LinkedIn: https://www.linkedin.com/in/lucas-soares-969044167/ - Tiktok: https://www.tiktok.com/@enkrateialucca?lang=en - Credits: - https://github.com/full-stack-deep-learning/conda-piptools - https://github.com/jazzband/pip-tools - https://github.com/full-stack-deep-learning/fsdl-text-recognizer-2021-labs/tree/main/setup ***If you liked this video don't forget to like, comment and subscribe! Thanks and see you next time! :)***
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Automata Learning Lab · Automata Learning Lab · 15 of 60

1 A Quick Tutorial on NLP Basics
A Quick Tutorial on NLP Basics
Automata Learning Lab
2 Automating your Digital Morning Routine with Python
Automating your Digital Morning Routine with Python
Automata Learning Lab
3 Exploring Problem Solving with Python and Jupyter Notebook #1
Exploring Problem Solving with Python and Jupyter Notebook #1
Automata Learning Lab
4 Summarize Papers with Python and GPT-3
Summarize Papers with Python and GPT-3
Automata Learning Lab
5 An Experiment Tracking Tutorial with Mlflow and Keras
An Experiment Tracking Tutorial with Mlflow and Keras
Automata Learning Lab
6 Automating Google Forms Submissions with Python
Automating Google Forms Submissions with Python
Automata Learning Lab
7 Productivity Tracking With Python and the Notion API
Productivity Tracking With Python and the Notion API
Automata Learning Lab
8 When your Machine Learning Model Fails Do This ;p
When your Machine Learning Model Fails Do This ;p
Automata Learning Lab
9 Machine Learning Tip#1 Practical Deep Learning Course
Machine Learning Tip#1 Practical Deep Learning Course
Automata Learning Lab
10 Machine Learning Tips: Deep Learning Monitor
Machine Learning Tips: Deep Learning Monitor
Automata Learning Lab
11 Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Machine Learning Tips#5 MLOPs specialization in Coursera #machinelearning
Automata Learning Lab
12 Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automatically Changing Desktop Wallpaper with Python and the Nasa Image API
Automata Learning Lab
13 Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Building an Image Classifier to Filter Out Unused Images From Your Photo Album with Machine Learning
Automata Learning Lab
14 Automating VS Code Snippets with Python
Automating VS Code Snippets with Python
Automata Learning Lab
How to Set Up a Machine Learning Environment with Conda and Pip-Tools
How to Set Up a Machine Learning Environment with Conda and Pip-Tools
Automata Learning Lab
16 9 Google Search Tips for Machine Learning
9 Google Search Tips for Machine Learning
Automata Learning Lab
17 Thinking Tools
Thinking Tools
Automata Learning Lab
18 Automating Car Search with Python and Data Science
Automating Car Search with Python and Data Science
Automata Learning Lab
19 Generating Images from Text with Stable Diffusion and Hugging Face
Generating Images from Text with Stable Diffusion and Hugging Face
Automata Learning Lab
20 A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
A Practical Introduction to Data Science using the Spaceship Titanic Dataset from Kaggle
Automata Learning Lab
21 Jiu Jitsu App with Python and Streamlit
Jiu Jitsu App with Python and Streamlit
Automata Learning Lab
22 2 Apps for Coding In The Ipad Pro
2 Apps for Coding In The Ipad Pro
Automata Learning Lab
23 From Tensorflow to Pytorch?
From Tensorflow to Pytorch?
Automata Learning Lab
24 Building an Audio Transcription App with OpenAI Whisper and Streamlit
Building an Audio Transcription App with OpenAI Whisper and Streamlit
Automata Learning Lab
25 Productivity Tracking with Python Short Summary
Productivity Tracking with Python Short Summary
Automata Learning Lab
26 Automating Expense Reports with Python
Automating Expense Reports with Python
Automata Learning Lab
27 ChatGPT, Angry Pandas and AI Code
ChatGPT, Angry Pandas and AI Code
Automata Learning Lab
28 7 Strategies To Learn Anything Using ChatGPT
7 Strategies To Learn Anything Using ChatGPT
Automata Learning Lab
29 Building a Thought Summarization App with Whisper and GPT3
Building a Thought Summarization App with Whisper and GPT3
Automata Learning Lab
30 Visualize a Neural Net Learning Polynomial Functions
Visualize a Neural Net Learning Polynomial Functions
Automata Learning Lab
31 Automating Notion with Python
Automating Notion with Python
Automata Learning Lab
32 Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Pose Tracking for Jiu Jitsu - Update #jiujitsu #machinelearning
Automata Learning Lab
33 Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Update to my Pose Tracking for Jiu Jitsu Project #machinelearning #jiujitsu #ai #deeplearning
Automata Learning Lab
34 ChatGPT API Released by OpenAI
ChatGPT API Released by OpenAI
Automata Learning Lab
35 ChatGPT API Response Format #machinelearning #ai #datascience
ChatGPT API Response Format #machinelearning #ai #datascience
Automata Learning Lab
36 Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Beyond Stable Diffusion with Composer | Automata Learning Lab Paper Series #1
Automata Learning Lab
37 Beyond Diffusion Models with Composer #machinelearning #ai
Beyond Diffusion Models with Composer #machinelearning #ai
Automata Learning Lab
38 Machine Learning for Jiu Jitsu
Machine Learning for Jiu Jitsu
Automata Learning Lab
39 Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Prompt Engineering Basics #machinelearning #gpt4 #chatgpt
Automata Learning Lab
40 Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Visual ChatGPT: Integrating Images with ChatGPT Paper Series#2
Automata Learning Lab
41 Visual ChatGPT #machinelearning #ai #artificialintelligence
Visual ChatGPT #machinelearning #ai #artificialintelligence
Automata Learning Lab
42 LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
LERF - Language Embeddings + NERF for Querying 3D Spaces #machinelearning #ai
Automata Learning Lab
43 Summarize Papers with Python and ChatGPT
Summarize Papers with Python and ChatGPT
Automata Learning Lab
44 Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Large Language Models can use Tools Now! #artificialintelligence #machinelearning #ai
Automata Learning Lab
45 Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Sparks of AGI in GPT4? #machinelearning #ai #agi #artificialintelligence
Automata Learning Lab
46 Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Toolformer: LLMs can use Tools! #chatgpt #llms #gpt4 #gpt3 #artificialintelligence
Automata Learning Lab
47 Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Talking to Your Notes with LangChain #artificialintelligence #llms #gpt4 #chatgpt
Automata Learning Lab
48 How to Talk to a PDF using LangChain and ChatGPT
How to Talk to a PDF using LangChain and ChatGPT
Automata Learning Lab
49 Query Your Own Notes With LangChain
Query Your Own Notes With LangChain
Automata Learning Lab
50 HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
HuggingGPT #machinelearning #artificialintelligence #huggingface #gpt4 #chatgpt
Automata Learning Lab
51 Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Do as I Can Not as I Say Paper #artificialintelligence #llms #reinforcementlearning
Automata Learning Lab
52 Automating Anki Flashcards with OpenAI and GPT-4
Automating Anki Flashcards with OpenAI and GPT-4
Automata Learning Lab
53 Building A PDF Summarization App with  Gradio and LangChain
Building A PDF Summarization App with Gradio and LangChain
Automata Learning Lab
54 Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Auto-GPT #artificialintelligence #gpt4 #llms #autogpt
Automata Learning Lab
55 DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
DocGPT - Chat with Github #artificialintelligence #gpt4 #chatgpt
Automata Learning Lab
56 LLMs for Research and Planning #artificialintelligence #gpt4 #llms
LLMs for Research and Planning #artificialintelligence #gpt4 #llms
Automata Learning Lab
57 How I Use ChatGPT for Interactive Language Learning
How I Use ChatGPT for Interactive Language Learning
Automata Learning Lab
58 Building an Audio Transcription App with Gradio and Whisper
Building an Audio Transcription App with Gradio and Whisper
Automata Learning Lab
59 Summarizing and Querying Multiple Papers with LangChain
Summarizing and Querying Multiple Papers with LangChain
Automata Learning Lab
60 Mojo - The New AI Programming Language?
Mojo - The New AI Programming Language?
Automata Learning Lab

This tutorial teaches viewers how to set up a machine learning environment using conda and pip-tools, covering the creation of a conda environment, installation of dependencies, and management of dependencies using pip-tools and makefiles. The tutorial provides a comprehensive guide to creating a hybrid environment for machine learning development. By following this tutorial, viewers can learn how to manage dependencies, create a consistent environment, and apply machine learning concepts to rea

Key Takeaways
  1. Create a conda environment with Python 3.7
  2. Activate the environment
  3. Install CUDA toolkit 10.2 for PyTorch
  4. Export the environment to an environment.yml file
  5. Create a requirements folder with dev and prod .in files
  6. Create a folder called requirements with two files: dev.txt and prod.txt
  7. List dependencies in dev.txt and prod.txt files
  8. Write a makefile to automate dependency management
  9. Use conda to update the environment and install dependencies
  10. Use pip to install dependencies from dev.txt and prod.txt files
💡 Using conda and pip-tools together can create a robust and deterministic environment for machine learning development, allowing for consistent and reproducible results.

Related Reads

📰
KMP Algorithm (Knuth-Morris-Pratt): The Smart Way to Perform String Matching in O(N)
Learn the KMP algorithm for efficient string matching in O(N) time complexity and improve your coding skills
Dev.to · Jaspreet singh
📰
Every Backtracking Problem Is the Same Three Lines. I Just Couldn't See the Tree.
Master backtracking problems with a simple three-line approach to improve problem-solving skills in coding interviews and challenges
Dev.to · Alex Mateo
📰
DSA From Zero to Hero #3: Sliding Window (Fixed Size) Explained With a Java Example
Learn to solve subarray problems efficiently using the sliding window technique, a crucial skill for software engineers and data scientists
Medium · Programming
📰
Two Pointers & Sliding Window: Turn O(n²) Into O(n)
Learn to optimize algorithms from O(n²) to O(n) using Two Pointers and Sliding Window techniques
Medium · Programming
Up next
Stump Grinder Carbide Wheel Grinds Hardwood To Chips
Innoforge Studio
Watch →