Conda environment setup

Installation using Anaconda or Miniconda package manager.

Advantages

  • Simplified dependency management

  • Easy environment switching

  • Cross-platform consistency

  • Integrated package solver

Prerequisites

  • Anaconda or Miniconda installed

  • NVIDIA GPU with drivers (for GPU support)

    • Or CPU-only mode (no GPU required)

  • 10GB free disk space

Installation steps

1. Install Conda

If you don’t have conda installed:

Miniconda (lightweight):

# Linux
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

# macOS
brew install miniconda

Anaconda (full distribution):

Verify installation:

conda --version

2. Clone repository

git clone https://github.com/YOUR_USERNAME/GANNs-with-friends.git
cd GANNs-with-friends

3. Create conda environment

With GPU:

conda env create -f environment.yml

CPU-only (no GPU):

conda env create -f .devcontainer/cpu/environment.yml

This creates an environment named ganns-with-friends (or ganns-with-friends-cpu) with all dependencies.

4. Activate environment

# GPU environment
conda activate ganns-with-friends

# CPU environment
conda activate ganns-with-friends-cpu

You should see the environment name in your prompt.

5. Verify installation

# Check Python version
python --version

# Check PyTorch
python -c "import torch; print(f'PyTorch: {torch.__version__}')"

# Check GPU (if using GPU environment)
python -c "import torch; print(f'CUDA: {torch.cuda.is_available()}')"

# Test imports
python -c "from src.models.dcgan import Generator; print('Models OK')"

6. Configure database

cp config.yaml.template config.yaml

Edit config.yaml:

database:
  host: YOUR_DATABASE_HOST
  port: 54321
  database: distributed_gan
  user: YOUR_USERNAME
  password: YOUR_PASSWORD

7. Start worker

python src/worker.py

On first run, the dataset will be automatically downloaded from Hugging Face (~1.4 GB).

Expected output:

Initializing worker...
Using GPU 0: NVIDIA GeForce RTX 3080
Loaded dataset with 202599 images
Worker abc123 initialized successfully!
Name: YourName
GPU: NVIDIA GeForce RTX 3080
Batch size: 32
Waiting for work units...

Managing conda environments

List environments

conda env list

Activate/deactivate

# Activate
conda activate ganns-with-friends

# Deactivate
conda deactivate

Update environment

If environment.yml changes:

conda env update -f environment.yml --prune

Export environment

Save your current environment:

conda env export > environment-freeze.yml

Remove environment

If you need to start fresh:

conda env remove -n ganns-with-friends

Environment files explained

environment.yml (GPU)

Includes:

  • Python 3.10

  • PyTorch with CUDA 12.6

  • torchvision with GPU support

  • PIL, PyYAML, psycopg2

  • huggingface-hub (via pip)

.devcontainer/cpu/environment.yml (CPU-only)

Same as above but:

  • PyTorch CPU-only build

  • Smaller download size

  • No CUDA dependencies

Troubleshooting

Solving environment takes forever:

  • Try mamba (faster solver): conda install mamba

  • Then use: mamba env create -f environment.yml

Conflicts with existing packages:

  • Use a fresh environment

  • Don’t mix pip and conda for same packages

CUDA version mismatch:

  • Check your driver: nvidia-smi

  • Adjust CUDA version in environment.yml

  • Available versions: 11.8, 12.1, 12.4, 12.6

Database module errors:

  • Install separately: conda install psycopg2

  • Or use binary: pip install psycopg2-binary

Environment activation fails:

  • Initialize conda: conda init bash (or your shell)

  • Restart shell

  • Try again

Next steps