Repository navigation
[ROCm][Windows] Fix Linux-only headers in CUDACachingAllocator.cpp - #176727
moonshadow-25 wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/176727
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (6 Unrelated Failures)As of commit 1a60019 with merge base b1a18c5 ( FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
|
|
@pytorchbot label "topic: not user facing" |
7c14422 to
4bcfbfd
Compare
|
/easycla |
4bcfbfd to
d302984
Compare
|
/easycla |
d302984 to
110ae8c
Compare
|
Oh nice, you beat me to it and I noticed just before submitting a pull request to temporarily disable it for windows. |
|
@ethanwee1 just pinging to make sure you're tracking since I see you were assigned ROCm/TheRock#3603 |
When building PyTorch with ROCm (USE_ROCM=ON) on Windows, the compiler fails with: fatal error: 'sys/syscall.h' file not found The file CUDACachingAllocator.cpp (and its HIPIFY-generated counterpart HIPCachingAllocator.cpp) includes Linux-only POSIX headers under the `USE_ROCM` preprocessor condition without guarding them for Windows: #if defined(PYTORCH_C10_DRIVER_API_SUPPORTED) || defined(USE_ROCM) #include <sys/syscall.h> // Linux only #include <sys/types.h> // Linux only #include <unistd.h> // Linux only #endif This patch adds `#ifndef _WIN32` guards around the Linux-only includes and adds `#include <process.h>` for Windows (provides `_getpid()`). Additional Windows-specific fixes in the same file: - `pid_t` (POSIX type) in `ShareHeader` struct -> `int` on Windows - `getpid()` -> `_getpid()` on Windows in `share()` - Guard `syscall(SYS_pidfd_open/getfd, ...)` with `#ifndef _WIN32` in `fromShared()` (Linux kernel IPC not available on Windows); add a `TORCH_CHECK(false, ...)` stub so the code still compiles and gives a clear runtime error if called - Guard `close()` of file descriptor in `unmapHandles()` with `#ifndef _WIN32` Tested on Windows 11 with AMD gfx1151 (Strix Halo iGPU), ROCm 7.12, clang-cl (MSVC-compatible frontend). PyTorch builds and `torch.cuda.is_available()` returns True.
110ae8c to
1a60019
Compare
|
Thanks @moonshadow-25 ! I will trigger a build on therock CI and see if this passes |
|
Thanks @ethanwee1 and @jeffdaily for the review and the CI run! Closing this as the upstream code has already addressed the ROCm+Windows |
|
The expandable segments PR #173330 got reverted. As part of the rework, I've cherry-picked this PR into it. Thanks for the contribution. |
When building PyTorch with ROCm (USE_ROCM=ON) on Windows, the compiler fails with:
fatal error: 'sys/syscall.h' file not found
The file CUDACachingAllocator.cpp (and its HIPIFY-generated counterpart HIPCachingAllocator.cpp) includes Linux-only POSIX headers under the
USE_ROCMpreprocessor condition without guarding them for Windows:#if defined(PYTORCH_C10_DRIVER_API_SUPPORTED) || defined(USE_ROCM)
#include <sys/syscall.h> // Linux only
#include <sys/types.h> // Linux only
#include <unistd.h> // Linux only
#endif
This patch adds
#ifndef _WIN32guards around the Linux-only includes and adds#include <process.h>for Windows (provides_getpid()).Additional Windows-specific fixes in the same file:
pid_t(POSIX type) inShareHeaderstruct ->inton Windowsgetpid()->_getpid()on Windows inshare()syscall(SYS_pidfd_open/getfd, ...)with#ifndef _WIN32infromShared()(Linux kernel IPC not available on Windows); add aTORCH_CHECK(false, ...)stub so the code still compiles and gives a clear runtime error if calledclose()of file descriptor inunmapHandles()with#ifndef _WIN32Tested on Windows 11 with AMD gfx1151 (Strix Halo iGPU), ROCm 7.12, clang-cl (MSVC-compatible frontend). PyTorch builds and
torch.cuda.is_available()returns True.cc @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @jataylo @hongxiayang @naromero77amd @pragupta @jerrymannil @xinyazhang