Set up your laptop for AI and ML in Python and .NET
Learning goal. Install and check a Python and a .NET environment for AI work, run notebooks, use Git, and understand when you need a GPU.
In plain words
You can learn almost all of AI and ML on an ordinary laptop. You need a programming environment, a few libraries and a place to save your work. Python has the largest set of AI libraries: NumPy and pandas (data), scikit-learn (classic ML), PyTorch (deep learning), and libraries for language models. .NET is strong for building business applications: ML.NET (classic ML), TorchSharp (deep learning), ONNX Runtime (run trained models fast), and Microsoft.Extensions.AI (call language models). A virtual environment keeps each Python project's libraries separate. Notebooks (Jupyter, or Polyglot Notebooks in VS Code for C#) let you run code step by step and see results. Git saves every version of your code. A GPU (graphics card) makes deep learning much faster, but it is only needed for bigger neural networks; small models train fine on a CPU, and you can rent GPUs in the cloud when you need them.
Python
- Data NumPy and pandas
- Classic ML scikit-learn
- Deep learning PyTorch
- Language models Libraries for language models
.NET
- Classic ML ML.NET
- Deep learning TorchSharp
- Run trained models fast ONNX Runtime
- Language models Microsoft.Extensions.AI
Both are covered in every lesson of this guide.
- Data storeGitSaves every version of your code
- ProcessNotebooksRun code step by step and see results
- ModelLibraries in a virtual environmentKept separate for each Python project
- InputPython and .NETInstalled on an ordinary laptop
Each layer sits on the one below it.
CPU
- Enough for Classic ML and small neural networks
GPU
- Helps with Much faster deep learning on bigger neural networks
- How to get one Rent in the cloud when you need it
Real-world example
A data team gives every new engineer a one-page setup script: create a virtual environment, install pinned library versions from requirements.txt, run a check script, open the starter notebook. Everyone gets identical results, and "it works on my machine" problems disappear.
- ProcessCreate a virtual environmentOne per project
- Data storeInstall pinned librariesFrom
requirements.txt - ProcessRun a check scriptConfirms the setup works
- OutputOpen the starter notebookSame results for everyone
How it works
- Install Python 3.10 or newer and the .NET SDK (version 8 or newer) and VS Code.
- Python: create a virtual environment and install libraries; record them in
requirements.txt. - .NET: create a project with
dotnet new consoleand add NuGet packages. - Run a check script in each language.
- Put the project in Git; never commit passwords or API keys.
- Optional: install a local model runner (such as Ollama) to run language models on your own machine.
Python
- InputInstall Python 3.10 or newerAnd VS Code
- ProcessCreate a virtual environmentInstall libraries
- Data storeRecord
requirements.txtPinned library versions - OutputRun the check scriptPython environment check
.NET
- InputInstall the .NET SDKVersion 8 or newer
- Process
dotnet new consoleCreate the project - Data storeAdd NuGet packagesLibraries for the project
- OutputRun the check script.NET environment check
Python example
python -m venv .venv
source .venv/bin/activate
pip install numpy pandas scikit-learn jupyter
pip freeze > requirements.txt
jupyter notebookimport platform, os, numpy as np, pandas as pd, sklearn
print(f"Python {platform.python_version()} | CPU cores: {os.cpu_count()}")
print(f"numpy {np.__version__} | pandas {pd.__version__} | scikit-learn {sklearn.__version__}")
try:
import torch
print(f"PyTorch {torch.__version__} | GPU available: {torch.cuda.is_available()}")
except ImportError:
print("PyTorch not installed (needed only for deep-learning lessons)")Python 3.13.18 on Linux | CPU cores: 2
numpy 2.5.3 | pandas 3.0.5 | scikit-learn 1.9.1
PyTorch not installed (needed only for deep-learning lessons)Your versions will differ; that is fine. When you reach the deep-learning lessons, install PyTorch using the command generator on its official site, choosing your operating system and whether you have an NVIDIA GPU.
.NET (C#) example
dotnet new console -n AiStarter
cd AiStarter
dotnet add package Microsoft.ML
dotnet add package Microsoft.Extensions.AI
dotnet runusing System.Runtime.InteropServices;
Console.WriteLine($".NET {Environment.Version} on {RuntimeInformation.OSDescription}");
Console.WriteLine($"CPU cores: {Environment.ProcessorCount}");
Console.WriteLine($"ML.NET loaded: {typeof(Microsoft.ML.MLContext).Assembly.GetName().Version}");For C# notebooks, install the Polyglot Notebooks extension in VS Code. For deep learning in .NET, add TorchSharp-cpu (or the CUDA build if you have an NVIDIA GPU).
Maths behind it
- None for setup. GPUs speed up linear algebra (matrix multiplication), which is the core operation of neural networks.
Common mistakes
- Installing libraries globally, then breaking one project while fixing another.
- Committing API keys to Git. Use environment variables or .NET user secrets.
- Buying an expensive GPU before you need one. Learn first; rent GPU time for big jobs.
Libraries installed globally
- Result Fixing one project can break another
One virtual environment per project
- Result Each project keeps its own library versions
- Bonus Setup can be recreated from
requirements.txt
Why each project gets its own environment.
- RiskAPI keyNever put it in code
- Data storeEnvironment variable or .NET user secretKept outside the repository
- OutputGit repositoryContains no passwords or keys
Quick check
Why use a virtual environment in Python?
Show answer
Each project gets its own library versions, so projects do not break each other and the setup can be recreated from
requirements.txt.Name one .NET library for classic ML and one for running trained models fast.
Show answer
ML.NET for classic ML; ONNX Runtime for fast inference of trained models.
Do you need a GPU to start learning?
Show answer
No. Classic ML and small neural networks run on a CPU; rent a GPU later for larger deep-learning work.
Completion
Evidence of completion. Both environment checks run on your machine, a Git repository with your first notebook, and a note of whether your laptop has a usable GPU.
Saved in this browser only. See all progress.