Skip to content

Deep Learning AMI (GPU PyTorch) default python

0

I've used Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.6.0 (Amazon Linux) image successfully (as described here), but recently there was a change that was bothering me. There was an upgrade to pytorch 2.7, which is not a problem, but something else changed too.

The discrepancies I've found:

  • "Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Amazon Linux 2023) 20250520" ami-071fef0aff49fae3e
    • default python is 3.12
    • pip is ready to use and libraries installed
  • "Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.6.0 (Amazon Linux 2023) 20250531" ami-078ab55619d448b95
    • default python is 3.12
    • pip is ready to use and libraries installed
  • "Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.7 (Amazon Linux 2023) 20250621" ami-05a6c2eaa7455911c
    • default python is 3.9
    • pip is not installed
    • pytorch is not installed
    • pyhton3.12 is available but not the default

Is there a reliable/consistent way to access the newest python and it's libraries? Or is it at the whim of AWS?

My problem is that my scripts break when a newer version of the DLAMI comes out and the default python changes, even within the same skew (Deep Learning OSS Nvidia Driver AMI GPU PyTorch 2.6.0 (Amazon Linux 2023) ????????)

1 Answer
0
Accepted Answer

Based on the AWS Deep Learning AMI documentation, the PyTorch 2.6 and 2.7 AMIs on Amazon Linux 2023 use Python 3.12 as the default Python version. The PyTorch framework is now installed in a Python virtual environment rather than using Anaconda (which was deprecated in PyTorch 2.6 and above).

To consistently access the correct Python environment with all the necessary libraries installed, you should activate the PyTorch virtual environment using:

source /opt/pytorch/bin/activate

This virtual environment contains PyTorch and all its dependencies. After activation, you'll have access to Python 3.12 with all the required libraries pre-installed.

The discrepancy you're experiencing with the June 21, 2025 AMI showing Python 3.9 as default and missing PyTorch installation doesn't align with the official documentation. According to the documentation, all the recent PyTorch 2.7 AMIs on Amazon Linux 2023 should be using Python 3.12 and have PyTorch pre-installed in the virtual environment.

For consistent access to the correct Python version and libraries across different DLAMI versions, I recommend:

  1. Always explicitly activate the PyTorch virtual environment in your scripts
  2. Use the full path to Python: /opt/pytorch/bin/python instead of relying on the system default

This approach should provide more consistency as AWS updates their AMIs over time.
Sources
AWS Deep Learning AMI GPU PyTorch 2.6 (Amazon Linux 2023) - AWS Deep Learning AMIs
AWS Deep Learning OSS AMI GPU PyTorch 2.7 (Amazon Linux 2023) - AWS Deep Learning AMIs
AWS Deep Learning ARM64 AMI OSS GPU PyTorch 2.7 (Amazon Linux 2023) - AWS Deep Learning AMIs
AWS Deep Learning OSS AMI GPU PyTorch 2.7 (Ubuntu 22.04) - AWS Deep Learning AMIs

answered 5 months ago
AWS
EXPERT
reviewed 5 months ago
  • Thanks, this works 🤗. Now that I search for it, I can find the environment activation mentioned in the dcumentation.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.