Isolated Network AI Training: Step-by-Step Guide
In this article
Running AI model training in an isolated network (also called an air-gapped environment) means you train models on machines that have no direct connection to the internet. This approach is used in high-security settings, classified projects, or when dealing with sensitive data that cannot leave your premises. This guide walks you through the entire process—from planning and preparing your hardware to installing dependencies, transferring data, and running the training itself—so you can get your model trained without ever going online.
What You'll Need
- A dedicated server or workstation with a compatible GPU (NVIDIA, AMD, or Apple Silicon) and enough RAM/VRAM for your model size.
- An offline copy of your training dataset (on a USB drive, external HDD, or internal storage).
- Access to a second, internet-connected machine (for downloading software and packages).
- A USB drive or portable SSD with sufficient capacity (at least 16GB, more if you need large datasets).
- An operating system installed on the isolated machine (Linux is recommended for most frameworks).
- Basic familiarity with the command line and your chosen ML framework (PyTorch, TensorFlow, etc.).
Step-by-Step
- Plan your training environment. Decide which ML framework (e.g., PyTorch, TensorFlow) and version you need. Check the framework’s documentation for specific CUDA/cuDNN versions if using NVIDIA GPUs. Note down every dependency you’ll need—this includes Python packages, system libraries, and drivers.
- Prepare a portable download station. On your internet-connected machine, create a folder called
offline_packages. This will hold all the files you’ll transfer. - Download the framework and dependencies. Use
pip downloadto fetch the exact packages and their dependencies. For example, for PyTorch with CUDA, run:pip download torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 -d ./offline_packages
Also download any additional packages you need (e.g., transformers, datasets, numpy, scipy). Usepip download -r requirements.txt -d ./offline_packagesif you have a requirements file. - Download CUDA and cuDNN (if using NVIDIA). Go to NVIDIA’s website and download the CUDA toolkit installer (the .run or .deb file) and the cuDNN library (requires a free account). Save these to your
offline_packagesfolder. - Download system libraries. If your isolated machine is missing any system libraries (like libopenblas, libgomp), download the .deb or .rpm files from the distro’s repository. Use
apt-get downloadon a Debian/Ubuntu machine ordnf downloadon Fedora. - Copy your training data. Place your dataset files (e.g., images, CSV, JSON) into the
offline_packagesfolder as well, or keep them separate on the same USB drive. - Transfer everything to the isolated machine. Plug the USB drive into the isolated machine and copy the entire
offline_packagesfolder to a local directory, e.g.,/home/user/offline_packages. - Install system dependencies. On the isolated machine, install the CUDA toolkit and cuDNN. For a .deb file, use
sudo dpkg -i cuda-toolkit.deb. For a .run file, runsudo sh cuda_*.run. Install any system libraries usingsudo dpkg -i *.deborsudo rpm -ivh *.rpm. - Set up a virtual environment. Create a Python virtual environment to avoid conflicts:
python3 -m venv myenvand activate it withsource myenv/bin/activate. - Install Python packages from local files. Use
pip install --no-index --find-links=./offline_packages torch torchvision torchaudioand then install the rest of your requirements withpip install --no-index --find-links=./offline_packages -r requirements.txt. The--no-indexflag tells pip not to look online. - Verify the installation. Run a quick test to ensure everything works:
python -c "import torch; print(torch.cuda.is_available())"should printTrueif CUDA is set up correctly. - Place your training script. Write or transfer your training script (e.g.,
train.py) to the isolated machine. Ensure it references the correct dataset path. - Run the training. Execute your script:
python train.py. Monitor the output for errors. If you need to run it in the background, usenohup python train.py > training.log 2>&1 &. - Monitor and manage. Check progress with
tail -f training.log. Usenvidia-smito see GPU usage. If training stalls, you can stop it withCtrl+C(orkillif backgrounded). - Save and export results. Once training completes, your model weights will be saved to the path specified in your script (e.g.,
model.pth). Copy them to a safe location, and if needed, transfer them out via USB.
Common Mistakes
- Forgetting to download all dependencies. It’s easy to miss a transitive dependency. Use
pip downloadwith the--no-depsflag? No—do the opposite: make sure to include all dependencies by usingpip downloadwithout--no-deps. - Mismatched CUDA versions. If your PyTorch build expects CUDA 11.8 but you installed 12.0, you’ll get runtime errors. Double-check the version compatibility.
- Not using a virtual environment. Installing packages globally can lead to conflicts, especially if you have multiple projects.
- Assuming the internet is available. On the isolated machine, never try to
pip installwithout--no-index—it will hang or fail. - Ignoring disk space. Datasets and model checkpoints can be huge. Ensure you have enough free space before starting.
Tips
- Document everything. Write down the exact versions of every package and library you use. This makes reproducing the environment easier later.
- Use a requirements.txt file. Even if you don’t have one, create one listing all your packages with versions. This helps when downloading on the internet machine.
- Test the training on a small subset. Before running the full training, test with a tiny slice of data to ensure the pipeline works.
- Keep a backup of the offline_packages folder. If you need to reinstall, you won’t have to download everything again.
- Consider using Docker. If you can pre-build a Docker image on the internet machine and export it as a tar file, you can load it on the isolated machine with
docker load. This simplifies dependency management.
Troubleshooting
- ImportError: libcuda.so.1: cannot open shared object file — This means CUDA drivers are not installed or not in the library path. Install the NVIDIA driver and CUDA toolkit, then run
sudo ldconfig. - pip install fails with “Could not find a version that satisfies the requirement” — You likely didn’t include all dependencies in the
--find-linksdirectory. Go back to the internet machine and download the missing package(s). - Out of memory during training — Reduce batch size, use gradient accumulation, or lower image resolution. Also check that no other processes are using GPU memory.
- Training is extremely slow — Ensure you’re actually using the GPU (check with
nvidia-smi). If CPU is being used, reinstall the GPU version of the framework. - System freezes or reboots during training — This could be a power supply issue or overheating. Check cooling and ensure the PSU can handle the GPU load.
- Can’t find dataset files — Double-check the path in your script. Use absolute paths to avoid confusion.
Frequently Asked Questions
- Can I use any ML framework in an isolated network? Yes, as long as you can download all its dependencies beforehand. PyTorch and TensorFlow both work offline once installed.
- Do I need a special license to run AI training offline? No, but you must comply with the licenses of the software you use (e.g., CUDA, cuDNN, and the ML framework). Most are free for research and commercial use, but check each one.
- How do I update the framework if I need a newer version later? You must download the newer version on an internet-connected machine, transfer it via USB, and reinstall. There’s no way to update without internet.
- Can I use cloud services to help with the download? Yes, you can use any internet-connected computer, including a cloud VM, to download packages. Just make sure to transfer them to the isolated machine.
- What if my dataset is too large to fit on a USB drive? Use an external hard drive or network transfer (if allowed) to move the data. You can also split the dataset into chunks and transfer sequentially.
- Is it possible to run distributed training across multiple isolated machines? Yes, you can set up a local network between the machines and use MPI or the framework’s distributed features. You’ll need to configure the network and ensure all machines have the same environment.