Get PyTorch Build and Environment Information

Get PyTorch Build and Environment Information

When working with PyTorch, it is important to have a good understand of the build and environment information. By knowing the specific build and environment details, you can identify potential compatibility or configuration problems and resolve them effectively. When sharing your work or collaborating with others, providing the PyTorch build and environment information ensures that others can accurately replicate your experiments or results. This tutorial explains how to get PyTorch build and environment information.

In the following code, we use the get_pretty_env_info function, which gathers environment information using various PyTorch and system utilities. It returns a formatted string containing details such as PyTorch version, CUDA version used to build PyTorch, Python version, available GPUs, and other relevant system configurations. The build information and collected environment information is printed to the console.

import torch.utils.collect_env as collect_env

info = collect_env.get_pretty_env_info()
print(info)

Here's an example of the output you might see when running the provided code:

PyTorch version: 2.0.1+cu118
Is debug build: False
CUDA used to build PyTorch: 11.8
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Clang version: Could not collect
CMake version: version 3.25.0
Libc version: glibc-2.35

Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.19.0-42-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.8.89
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3070 Laptop GPU
Nvidia driver version: 530.41.03
...

Leave a Comment

Cancel reply

Your email address will not be published.