- Newest
- Most votes
- Most comments
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:
- Always explicitly activate the PyTorch virtual environment in your scripts
- Use the full path to Python:
/opt/pytorch/bin/pythoninstead 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
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 7 months ago

Thanks, this works 🤗. Now that I search for it, I can find the environment activation mentioned in the dcumentation.