Skip to content

Commit

Permalink
update pytorch vision patches
Browse files Browse the repository at this point in the history
Signed-off-by: Mika Laitio <[email protected]>
  • Loading branch information
lamikr committed Jan 27, 2024
1 parent ba46459 commit 8ffe0d8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
From ac1370de3607d441a3cf98602593f662ae521621 Mon Sep 17 00:00:00 2001
From 5598268c127db6b024c18e7f7417e046c46a0199 Mon Sep 17 00:00:00 2001
From: Mika Laitio <[email protected]>
Date: Mon, 11 Dec 2023 09:18:53 -0800
Subject: [PATCH] pytorch_vision rocm build and package scripts
Subject: [PATCH 1/2] pytorch_vision rocm build and package scripts

Signed-off-by: Mika Laitio <[email protected]>
---
build_pytorch_vision_rocm.sh | 16 ++++++++++++++++
package_pytorch_vision_rocm_wheel.sh | 14 ++++++++++++++
2 files changed, 30 insertions(+)
build_pytorch_vision_rocm.sh | 18 ++++++++++++++++++
package_pytorch_vision_rocm_wheel.sh | 16 ++++++++++++++++
2 files changed, 34 insertions(+)
create mode 100755 build_pytorch_vision_rocm.sh
create mode 100755 package_pytorch_vision_rocm_wheel.sh

diff --git a/build_pytorch_vision_rocm.sh b/build_pytorch_vision_rocm.sh
new file mode 100755
index 0000000000..145b3878a4
index 0000000000..4078c95b93
--- /dev/null
+++ b/build_pytorch_vision_rocm.sh
@@ -0,0 +1,16 @@
@@ -0,0 +1,18 @@
+if [ -z "$1" ]; then
+ install_dir_prefix_rocm=/opt/rocm
+ echo "No rocm_root_directory_specified, using default: ${install_dir_prefix_rocm}"
Expand All @@ -30,15 +30,17 @@ index 0000000000..145b3878a4
+unset CFLAGS
+unset CPPFLAGS
+unset PKG_CONFIG_PATH
+export CMAKE_C_COMPILER=gcc
+export CMAKE_CXX_COMPILER=g++
+#export CMAKE_C_COMPILER=gcc
+#export CMAKE_CXX_COMPILER=g++
+export CMAKE_C_COMPILER=${install_dir_prefix_rocm}/bin/hipcc
+export CMAKE_CXX_COMPILER=${install_dir_prefix_rocm}/bin/hipcc
+ROCM_PATH=${install_dir_prefix_rocm} FORCE_CUDA=1 TORCHVISION_USE_NVJPEG=0 TORCHVISION_USE_VIDEO_CODEC=0 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} python setup.py install
diff --git a/package_pytorch_vision_rocm_wheel.sh b/package_pytorch_vision_rocm_wheel.sh
new file mode 100755
index 0000000000..34ae1ad841
index 0000000000..6cad095eeb
--- /dev/null
+++ b/package_pytorch_vision_rocm_wheel.sh
@@ -0,0 +1,14 @@
@@ -0,0 +1,16 @@
+if [ -z "$1" ]; then
+ install_dir_prefix_rocm=/opt/rocm
+ echo "No rocm_root_directory_specified, using default: ${install_dir_prefix_rocm}"
Expand All @@ -50,9 +52,11 @@ index 0000000000..34ae1ad841
+unset CFLAGS
+unset CPPFLAGS
+unset PKG_CONFIG_PATH
+export CMAKE_C_COMPILER=gcc
+export CMAKE_CXX_COMPILER=g++
+#export CMAKE_C_COMPILER=gcc
+#export CMAKE_CXX_COMPILER=g++
+export CMAKE_C_COMPILER=${install_dir_prefix_rocm}/bin/hipcc
+export CMAKE_CXX_COMPILER=${install_dir_prefix_rocm}/bin/hipcc
+FORCE_CUDA=1 TORCHVISION_USE_NVJPEG=0 TORCHVISION_USE_VIDEO_CODEC=0 CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} python setup.py bdist_wheel
--
2.43.0
2.41.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 6185798138986f53a8bc8406117f82876cf4f268 Mon Sep 17 00:00:00 2001
From: Mika Laitio <[email protected]>
Date: Fri, 26 Jan 2024 15:19:56 -0800
Subject: [PATCH 2/2] fix build error with hipcc

Following error occured when building with hipcc
instead of gcc/g++.

csrc/io/image/cpu/encode_jpeg.cpp:107:7: error: no matching function for call to 'from_blob'
torch::from_blob(jpegBuf, {(long)jpegSize}, ::free, options);

Signed-off-by: Mika Laitio <[email protected]>
---
torchvision/csrc/io/image/cpu/encode_jpeg.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/torchvision/csrc/io/image/cpu/encode_jpeg.cpp b/torchvision/csrc/io/image/cpu/encode_jpeg.cpp
index d2ed73071a..eada131d32 100644
--- a/torchvision/csrc/io/image/cpu/encode_jpeg.cpp
+++ b/torchvision/csrc/io/image/cpu/encode_jpeg.cpp
@@ -103,7 +103,7 @@ torch::Tensor encode_jpeg(const torch::Tensor& data, int64_t quality) {

torch::TensorOptions options = torch::TensorOptions{torch::kU8};
auto out_tensor =
- torch::from_blob(jpegBuf, {(long)jpegSize}, ::free, options);
+ torch::from_blob(jpegBuf, {(long)jpegSize}, std::free, options);
jpegBuf = nullptr;
return out_tensor;
}
--
2.41.0

0 comments on commit 8ffe0d8

Please sign in to comment.