pip로 TensorFlow 설치

이 가이드는 TensorFlow의 최신 안정 버전을 위한 것입니다. 미리보기 빌드 (nightly) 의 경우 tf-nightly 라는 pip 패키지를 사용합니다. 이전 TensorFlow 버전 요구 사항은 다음 표를 참조하세요. CPU 전용 빌드의 경우 tensorflow-cpu 라는 pip 패키지를 사용합니다.

다음은 설치 명령의 빠른 버전입니다. 단계별 지침을 보려면 아래로 스크롤하세요.

리눅스

python3 -m pip install tensorflow[and-cuda]
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

맥 OS

# There is currently no official GPU support for MacOS.
python3 -m pip install tensorflow
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

윈도우 네이티브

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
# Anything above 2.10 is not supported on the GPU on Windows Native
python -m pip install "tensorflow<2.11"
# Verify the installation:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

윈도우 WSL2

python3 -m pip install tensorflow[and-cuda]
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

CPU

python3 -m pip install tensorflow
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

야간

python3 -m pip install tf-nightly
# Verify the installation:
python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

하드웨어 요구 사항

다음 GPU 지원 장치가 지원됩니다.

  • CUDA® 아키텍처 3.5, 5.0, 6.0, 7.0, 7.5, 8.0 이상을 지원하는 NVIDIA® GPU 카드. CUDA® 지원 GPU 카드 목록을 참조하세요.
  • 지원되지 않는 CUDA® 아키텍처가 있는 GPU의 경우, PTX에서 JIT 컴파일을 피하거나 NVIDIA® 라이브러리의 다른 버전을 사용하려면 소스 에서 Linux 빌드 가이드를 참조하세요.
  • 패키지에는 지원되는 최신 CUDA® 아키텍처를 제외하고 PTX 코드가 포함되어 있지 않습니다. 따라서 CUDA_FORCE_PTX_JIT=1 설정된 경우 TensorFlow는 이전 GPU에서 로드되지 않습니다. (자세한 내용은 애플리케이션 호환성을 참조하세요.)

시스템 요구 사항

  • Ubuntu 16.04 이상(64비트)
  • macOS 10.12.6(Sierra) 이상(64비트) (GPU 지원 없음)
  • Windows 기본 - Windows 7 이상(64비트) (TF 2.10 이후 GPU 지원 없음)
  • Windows WSL2 - Windows 10 19044 이상(64비트)

소프트웨어 요구사항

다음 NVIDIA® 소프트웨어는 GPU 지원에만 필요합니다.

단계별 지침

리눅스

1. 시스템 요구사항

  • Ubuntu 16.04 이상(64비트)

TensorFlow는 공식적으로 Ubuntu만 지원합니다. 그러나 다음 지침은 다른 Linux 배포판에서도 작동할 수 있습니다.

2. GPU 설정

CPU에서만 TensorFlow를 실행하는 경우 이 섹션을 건너뛸 수 있습니다.

NVIDIA GPU 드라이버가 없으면 설치하세요. 다음 명령을 사용하여 설치되었는지 확인할 수 있습니다.

nvidia-smi

3. 텐서플로우 설치

TensorFlow에는 최신 버전의 pip가 필요하므로 최신 버전을 실행하려면 pip 설치를 업그레이드하세요.

pip install --upgrade pip

그런 다음 pip를 사용하여 TensorFlow를 설치합니다.

# For GPU users
pip install tensorflow[and-cuda]
# For CPU users
pip install tensorflow

4. 설치 확인

CPU 설정을 확인합니다.

python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

텐서가 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

GPU 설정을 확인합니다.

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

GPU 장치 목록이 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

맥 OS

1. 시스템 요구사항

  • macOS 10.12.6(Sierra) 이상(64비트)

현재 MacOS에서 TensorFlow를 실행하기 위한 공식 GPU 지원은 없습니다. 다음 지침은 CPU에서 실행하기 위한 것입니다.

2. Python 버전 확인

Python 환경이 이미 구성되어 있는지 확인하세요.

python3 --version
python3 -m pip --version

3. 텐서플로우 설치

TensorFlow에는 최신 버전의 pip가 필요하므로 최신 버전을 실행하려면 pip 설치를 업그레이드하세요.

pip install --upgrade pip

그런 다음 pip를 사용하여 TensorFlow를 설치합니다.

pip install tensorflow

4. 설치 확인

python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

텐서가 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

윈도우 네이티브

1. 시스템 요구사항

  • Windows 7 이상(64비트)

2. Microsoft Visual C++ 재배포 가능 패키지 설치

Visual Studio 2015, 2017 및 2019용 Microsoft Visual C++ 재배포 가능 패키지를 설치합니다. TensorFlow 2.1.0 버전부터 이 패키지에는 msvcp140_1.dll 파일이 필요합니다(이전 재배포 가능 패키지에서는 제공되지 않을 수 있음). 재배포 가능 패키지는 Visual Studio 2019 와 함께 제공되지만 별도로 설치할 수 있습니다.

  1. Microsoft Visual C++ 다운로드 로 이동합니다.
  2. 페이지를 아래로 스크롤하여 Visual Studio 2015, 2017 및 2019 섹션으로 이동합니다.
  3. 해당 플랫폼에 맞는 Visual Studio 2015, 2017 및 2019용 Microsoft Visual C++ 재배포 가능 패키지를 다운로드하여 설치하세요.

Windows에서 긴 경로가 활성화되어 있는지 확인하십시오.

3. 미니콘다 설치

Miniconda 는 GPU를 지원하는 TensorFlow를 설치하는 데 권장되는 접근 방식입니다. 시스템에 설치된 소프트웨어가 변경되지 않도록 별도의 환경을 생성합니다. 이는 특히 GPU 설정에 필요한 소프트웨어를 설치하는 가장 쉬운 방법이기도 합니다.

Miniconda Windows 설치 프로그램을 다운로드합니다. 다운로드한 파일을 두 번 클릭하고 화면의 지시를 따릅니다.

4. 콘다 환경 만들기

다음 명령을 사용하여 tf 라는 새 conda 환경을 만듭니다.

conda create --name tf python=3.9

다음 명령을 사용하여 비활성화하고 활성화할 수 있습니다.

conda deactivate
conda activate tf

나머지 설치 과정에서 활성화되어 있는지 확인하십시오.

5. GPU 설정

TensorFlow를 CPU에서만 실행하는 경우 이 섹션을 건너뛸 수 있습니다.

아직 NVIDIA GPU 드라이버가 없다면 먼저 설치하세요.

그런 다음 conda와 함께 CUDA, cuDNN을 설치하십시오.

conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

6. 텐서플로우 설치

TensorFlow에는 최신 버전의 pip가 필요하므로 최신 버전을 실행하려면 pip 설치를 업그레이드하세요.

pip install --upgrade pip

그런 다음 pip를 사용하여 TensorFlow를 설치합니다.

# Anything above 2.10 is not supported on the GPU on Windows Native
pip install "tensorflow<2.11" 

7. 설치 확인

CPU 설정을 확인합니다.

python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

텐서가 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

GPU 설정을 확인합니다.

python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

GPU 장치 목록이 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

윈도우 WSL2

1. 시스템 요구사항

  • Windows 10 19044 이상(64비트). 이는 Windows 10 버전 21H2, 2021년 11월 업데이트에 해당합니다.

다음 문서를 참조하세요.

2. GPU 설정

CPU에서만 TensorFlow를 실행하는 경우 이 섹션을 건너뛸 수 있습니다.

NVIDIA GPU 드라이버가 없으면 설치하세요. 다음 명령을 사용하여 설치되었는지 확인할 수 있습니다.

nvidia-smi

3. 텐서플로우 설치

TensorFlow에는 최신 버전의 pip가 필요하므로 최신 버전을 실행하려면 pip 설치를 업그레이드하세요.

pip install --upgrade pip

그런 다음 pip를 사용하여 TensorFlow를 설치합니다.

# For GPU users
pip install tensorflow[and-cuda]
# For CPU users
pip install tensorflow

4. 설치 확인

CPU 설정을 확인합니다.

python3 -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

텐서가 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

GPU 설정을 확인합니다.

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

GPU 장치 목록이 반환되면 TensorFlow가 성공적으로 설치된 것입니다.

패키지 위치

몇 가지 설치 메커니즘에는 TensorFlow Python 패키지의 URL이 필요합니다. 지정하는 값은 Python 버전에 따라 다릅니다.

버전 URL
리눅스
Python 3.9 GPU 지원 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-2.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Python 3.9 CPU 전용 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.15.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Python 3.10 GPU 지원 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-2.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Python 3.10 CPU 전용 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.15.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Python 3.11 GPU 지원 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-2.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Python 3.11 CPU 전용 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow_cpu-2.15.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
macOS(CPU 전용)
파이썬 3.9 https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.15.0-cp39-cp39-macosx_10_15_x86_64.whl
파이썬 3.10 https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.15.0-cp310-cp310-macosx_10_15_x86_64.whl
파이썬 3.11 https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-2.15.0-cp311-cp311-macosx_10_15_x86_64.whl
윈도우
Python 3.9 CPU 전용 https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.15.0-cp39-cp39-win_amd64.whl
Python 3.10 CPU 전용 https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.15.0-cp310-cp310-win_amd64.whl
Python 3.11 CPU 전용 https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow_cpu-2.15.0-cp311-cp311-win_amd64.whl