vision icon indicating copy to clipboard operation
vision copied to clipboard

Build fails: error: unknown type name 'j_decompress_ptr'

Open yurivict opened this issue 1 year ago • 2 comments

🐛 Describe the bug

FAILED: /usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/build/temp.freebsd-14.0-STABLE-amd64-cpython-39/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/decode_png.o 
c++ -MMD -MF /usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/build/temp.freebsd-14.0-STABLE-amd64-cpython-39/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/decode_png.o.d -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -fPIC -DPNG_FOUND=1 -DJPEG_FOUND=0 -DNVJPEG_FOUND=0 -I/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc -I/usr/local/include/libpng16 -I/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc -I/usr/local/lib/python3.9/site-packages/torch/include -I/usr/local/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.9/site-packages/torch/include/TH -I/usr/local/lib/python3.9/site-packages/torch/include/THC -I/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image -I/usr/local/lib/python3.9/site-packages/torch/include -I/usr/local/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/usr/local/lib/python3.9/site-packages/torch/include/TH -I/usr/local/lib/python3.9/site-packages/torch/include/THC -I/usr/local/include/python3.9 -c -c /usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/decode_png.cpp -o /usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/build/temp.freebsd-14.0-STABLE-amd64-cpython-39/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/decode_png.o -g0 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_clang"' '-DPYBIND11_STDLIB="_libcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1002"' -DTORCH_EXTENSION_NAME=image -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++17
In file included from /usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/decode_png.cpp:3:
/usr/ports/misc/py-torchvision/work-py39/vision-0.18.0/torchvision/csrc/io/image/cpu/exif.h:200:40: error: unknown type name 'j_decompress_ptr'
  200 | inline int fetch_jpeg_exif_orientation(j_decompress_ptr cinfo) {
      |                                        ^
1 error generated.

Versions

0.18.0 pytorch-2.2.2 clang-18 Python-3.9

yurivict avatar Apr 25 '24 15:04 yurivict

@yurivict Can you please share the snippet you used to build torchvision? As well as the full output of

wget https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

NicolasHug avatar Apr 29 '24 10:04 NicolasHug

I had the same error and got things to compile by editing vision-0.18.0/torchvision/csrc/io/image/cpu/exif.h. Specifically, I moved #include <jpeglib.h> to outside the #if JPEG_FOUND condition. Further down in this file you can see that it makes use of j_decompress_ptr both under the condition #if JPEG_FOUND and under #else. I'm not sure whether the latter is deliberate, as I can see that the relevant lines are:

#else // #if JPEG_FOUND
inline int fetch_jpeg_exif_orientation(j_decompress_ptr cinfo) {
  return -1;
}
#endif // #if JPEG_FOUND

This indicates that perhaps this used to be #if JPEG_FOUND but has been changed. I didn't test this yet, but my guess is that if these lines had been changed back to #if JPEG_FOUND instead of #else, then that would have also solved the problem, because j_decompress_ptr would not be needed anywhere.

Hope that helps!

lrhammond avatar May 02 '24 17:05 lrhammond

Thanks @lrhammond .

I suspect we've fixed that build issue already (probably in https://github.com/pytorch/vision/pull/8342/files) because the lines you're referring to aren't present in the code anymore. I suspect the latest changes weren't pulled in when you tried to build from source?

I'll close this issue as I believe if it has been resolved, but please feel free to re-open a new one if the build keeps failing on the latest main branch.

NicolasHug avatar May 14 '24 13:05 NicolasHug

0.18.1 (released on May 20 after your last comment on May 20) still has this problem.

log

yurivict avatar Jun 07 '24 15:06 yurivict

Same (on v0.18.1) but error is ‘j_decompress_ptr’ was not declared in this scope building from source

Seems like installing LibJpegTurbo should fix but hasn't for me yet - maybe something on my end though.

matthost avatar Jun 14 '24 15:06 matthost

Sorry folks, I would have to double check but what's probably happening is that we fixed the compilation issue on main but did not cherry-pick it onto the release branche(s).

NicolasHug avatar Jun 14 '24 15:06 NicolasHug

Updating TORCHVISION_INCLUDE to include the dir with jpeglib.h fixed the error for me. But yeah better if it worked as expected in the release :)

matthost avatar Jun 14 '24 16:06 matthost