Я запустил это в файле PowerShell и немедленно выполнил сценарий Python, убедившись, что вызываю его напрямую, а не полагаюсь на пакетный файл для его запуска. Все это делается в среде conda с помощью Python 3.8.19.
Вот как я устанавливаю переменные среды перед запуском сценария Python:
Код: Выделить всё
# Enable expandable CUDA segments for PyTorch (temporary)
$env:PYTORCH_CUDA_ALLOC_CONF = "max_split_size_mb:512,expandable_segments:True"
$env:CUDA_VISIBLE_DEVICES = "0"
Код: Выделить всё
Torch: 2.4.1
CUDA version: 12.4
CUDA available: True
Device: NVIDIA GeForce RTX 4070
OS: Windows 11
Код: Выделить всё
Testing CUDA expandable memory...
unified_memory_being_used.py:9: UserWarning: expandable_segments not supported on this platform (Triggered internally at C:\cb\pytorch_1000000000000\work\c10/cuda/CUDAAllocatorConfig.h:28.)
x = torch.empty((10_000, 10_000, 10_000), device="cuda") # ~4x larger than 12GB VRAM
CUDA OOM: CUDA out of memory. Tried to allocate 3725.29 GiB. GPU 0 has a total capacity of 11.99 GiB of which 10.83 GiB is free. Of the allocated memory 0 bytes is allocated by PyTorch, and 0 bytes is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
Подробнее здесь: https://stackoverflow.com/questions/798 ... y-runs-out
Мобильная версия