Setting up an AI development environment on a local machine
A properly configured local environment is the foundation of an AI developer's productivity. Key requirements include: isolation of dependencies between projects, convenient GPU support (if available), integration with cloud resources for model training, and code and data versioning.
Conda as a basis for isolation
# Установка Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
# Базовое окружение для AI-разработки
conda create -n ai-dev python=3.11
conda activate ai-dev
# Core ML stack
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
pip install transformers datasets peft accelerate
pip install scikit-learn xgboost lightgbm catboost
pip install pandas numpy scipy matplotlib seaborn plotly
pip install mlflow dvc[s3] great_expectations
pip install jupyter jupyterlab ipywidgets
pip install pytest black isort mypy pre-commit
VS Code Configuration for AI Development
.vscode/settings.json:
{
"python.defaultInterpreterPath": "~/miniconda3/envs/ai-dev/bin/python",
"python.formatting.provider": "black",
"editor.formatOnSave": true,
"jupyter.notebookFileRoot": "${workspaceFolder}",
"python.testing.pytestEnabled": true,
"files.exclude": {
"**/__pycache__": true,
"**/*.pyc": true,
".dvc": false
}
}
GPU profiling locally
# PyTorch Profiler для анализа GPU-операций
with torch.profiler.profile(
activities=[
torch.profiler.ProfilerActivity.CPU,
torch.profiler.ProfilerActivity.CUDA,
],
record_shapes=True,
profile_memory=True,
) as prof:
output = model(input_tensor)
print(prof.key_averages().table(sort_by="cuda_time_total", row_limit=10))
# Экспорт в Chrome trace
prof.export_chrome_trace("trace.json")
Cloud development for resource-intensive tasks
For local development without a powerful GPU: VS Code Remote SSH connects to a cloud GPU instance. Code is stored locally (Git), data is in S3/GCS, and computation is in the cloud. This is cheaper than maintaining a local GPU and more convenient than working in the browser-based Jupyter.
Key: ~/.ssh/config with aliases for GPU instances + automatic mounting of the remote filesystem via SSHFS for transparent work with remote files.







