Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Support px2 #280

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

WIP Support px2 #280

wants to merge 2 commits into from

Conversation

wangkuiyi
Copy link
Owner

@wangkuiyi wangkuiyi commented Sep 1, 2020

Fix #279

This PR solves the linking of pytorch/xla to libcgotorch.so. In the next PR, I will try to add some wrapper code.

@wangkuiyi
Copy link
Owner Author

wangkuiyi commented Sep 1, 2020

I am using the libtorch pre-built for rpi-aarch64. The script cgotorch/build.sh generates libcgotorch.so successfully.

However, go test ./... cannot load and use libtorch correctly.

By installing libomp-dev using sudo apt-get install -y libomp-dev, I can remove error messages complaining cannot find the OpenMP library. But, there are still errors about the glibc version.

11:09 $ go test ./...
# github.com/wangkuiyi/gotorch
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `exp2@GLIBC_2.29'
./cgotorch/libtorch/lib/libc10.so: undefined reference to `std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >::basic_stringstream()@GLIBCXX_3.4.26'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `exp@GLIBC_2.29'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `__cxa_init_primary_exception@CXXABI_1.3.11'
./cgotorch/libtorch/lib/libc10.so: undefined reference to `typeinfo for std::thread::_State@GLIBCXX_3.4.22'
./cgotorch/libtorch/lib/libc10.so: undefined reference to `std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)())@GLIBCXX_3.4.22'
./cgotorch/libtorch/lib/libc10.so: undefined reference to `std::thread::_State::~_State()@GLIBCXX_3.4.22'
./cgotorch/libtorch/lib/libtensorpipe.so: undefined reference to `fcntl64@GLIBC_2.28'
./cgotorch/libtorch/lib/libc10.so: undefined reference to `std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >::basic_ostringstream()@GLIBCXX_3.4.26'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `std::__exception_ptr::exception_ptr::exception_ptr(void*)@CXXABI_1.3.11'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `log@GLIBC_2.29'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `powf@GLIBC_2.27'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `expf@GLIBC_2.27'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `exp2f@GLIBC_2.27'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `log2@GLIBC_2.29'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `pow@GLIBC_2.29'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `log2f@GLIBC_2.27'
./cgotorch/libtorch/lib/libtorch_cpu.so: undefined reference to `logf@GLIBC_2.27'

The reason might be the glibc of Ubuntu 16.04 on my Drive PX2 is too old -- 2.23.

11:09 $ aptitude show libc6
Package: libc6
State: installed
Automatically installed: no
Multi-Arch: same
Version: 2.23-0ubuntu11.2
Priority: required
Section: libs
Maintainer: Ubuntu Developers <[email protected]>
Architecture: arm64
Uncompressed Size: 9,529 k
Depends: libgcc1
Suggests: glibc-doc, debconf | debconf-2.0, locales
Breaks: hurd (< 1:0.5.git20140203-1), libtirpc1 (< 0.2.3), locales (< 2.23), locales-all (< 2.23), nscd (< 2.23)
Description: GNU C Library: Shared libraries
 Contains the standard libraries that are used by nearly all programs on the system. This package includes shared versions of the standard C library and the standard math library, as
 well as many others.
Homepage: http://www.gnu.org/software/libc/libc.html

@wangkuiyi wangkuiyi changed the title Support px2 WIP Support px2 Sep 1, 2020
@wangkuiyi wangkuiyi requested a review from ljk53 September 1, 2020 18:12
@codecov
Copy link

codecov bot commented Sep 1, 2020

Codecov Report

Merging #280 into develop will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #280      +/-   ##
===========================================
+ Coverage    79.95%   79.96%   +0.01%     
===========================================
  Files           37       37              
  Lines         1751     1752       +1     
===========================================
+ Hits          1400     1401       +1     
  Misses         270      270              
  Partials        81       81              
Impacted Files Coverage Δ
vision/datasets/mnist.go 92.45% <100.00%> (+0.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 556963c...02dc420. Read the comment docs.

@wangkuiyi
Copy link
Owner Author

wangkuiyi commented Sep 1, 2020

After upgrading Ubuntu on PX2 from 16.04 to 18.04, I got glibc 2.27, which is still older than the version 2.29 used by pre-built libtorch.

So, I am building libtorch on PX2. However, the building failed as building an assembly source file.

[343/3718] Building ASM object confu-deps/pytorch_qnnpack/CMakeFiles/pytorch_qnnpack.dir/src/q8gemm/8x8-dq-aarch64-neon.S.o
FAILED: confu-deps/pytorch_qnnpack/CMakeFiles/pytorch_qnnpack.dir/src/q8gemm/8x8-dq-aarch64-neon.S.o
/usr/lib/ccache/cc -DCPUINFO_SUPPORTED_PLATFORM=1 -DFXDIV_USE_INLINE_ASSEMBLY=0 -DPYTORCH_QNNPACK_RUNTIME_QUANTIZATION=1 -isystem ../third_party/protobuf/src -isystem ../third_party/gemmlowp -isystem ../third_party/neon2sse -I../aten/src/ATen/native/quantized/cpu/qnnpack/include -I../aten/src/ATen/native/quantized/cpu/qnnpack/src -I../third_party/cpuinfo/deps/clog/include -I../third_party/cpuinfo/include -I../third_party/pthreadpool/include -I../third_party/FXdiv/include -I../third_party/psimd/include -I../third_party/FP16/include -O3 -DNDEBUG -fPIC   -pthread -MD -MT confu-deps/pytorch_qnnpack/CMakeFiles/pytorch_qnnpack.dir/src/q8gemm/8x8-dq-aarch64-neon.S.o -MF confu-deps/pytorch_qnnpack/CMakeFiles/pytorch_qnnpack.dir/src/q8gemm/8x8-dq-aarch64-neon.S.o.d -o confu-deps/pytorch_qnnpack/CMakeFiles/pytorch_qnnpack.dir/src/q8gemm/8x8-dq-aarch64-neon.S.o -c ../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S: Assembler messages:
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:690: Error: operand mismatch -- `mov V8.4s,V9.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:690: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:690: Info:    	mov v8.8b, v9.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:690: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:690: Info:    	mov v8.16b, v9.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:691: Error: operand mismatch -- `mov v10.4s,v11.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:691: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:691: Info:    	mov v10.8b, v11.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:691: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:691: Info:    	mov v10.16b, v11.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:692: Error: operand mismatch -- `mov v12.4s,V13.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:692: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:692: Info:    	mov v12.8b, v13.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:692: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:692: Info:    	mov v12.16b, v13.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:693: Error: operand mismatch -- `mov V14.4s,V15.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:693: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:693: Info:    	mov v14.8b, v15.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:693: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:693: Info:    	mov v14.16b, v15.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:694: Error: operand mismatch -- `mov V16.4s,V17.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:694: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:694: Info:    	mov v16.8b, v17.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:694: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:694: Info:    	mov v16.16b, v17.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:695: Error: operand mismatch -- `mov V18.4s,V19.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:695: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:695: Info:    	mov v18.8b, v19.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:695: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:695: Info:    	mov v18.16b, v19.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:696: Error: operand mismatch -- `mov V20.4s,V21.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:696: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:696: Info:    	mov v20.8b, v21.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:696: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:696: Info:    	mov v20.16b, v21.16b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:697: Error: operand mismatch -- `mov V22.4s,V23.4s'
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:697: Info:    did you mean this?
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:697: Info:    	mov v22.8b, v23.8b
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:697: Info:    other valid variant(s):
../aten/src/ATen/native/quantized/cpu/qnnpack/src/q8gemm/8x8-dq-aarch64-neon.S:697: Info:    	mov v22.16b, v23.16b
[346/3718] Building C object confu-deps/NNPACK/CMakeFiles/nnpack.dir/src/init.c.o

@wangkuiyi
Copy link
Owner Author

As described in ljk53/pytorch-rpi#2, I successfully built libtorch for PX2.

Copy link
Collaborator

@ljk53 ljk53 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build for NVIDIA Drive PX2
2 participants