# Build failed with TBB

**URL:** <https://discuss.pytorch.org/t/build-failed-with-tbb/123576>\
**Category:** jit\
**Created:** [June 8, 2021, 7:35am UTC](https://discuss.pytorch.org/t/build-failed-with-tbb/123576 "2021-06-08T07:35:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vlad\_Dumitru](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/vlad_dumitru/32/17919_2.png) [@Vlad\_Dumitru](https://discuss.pytorch.org/u/Vlad_Dumitru)\
**Post date:** [June 8, 2021, 7:35am UTC](https://discuss.pytorch.org/t/build-failed-with-tbb/123576/1 "2021-06-08T07:35:47Z")

</div>

I am trying to build PyTorch from source using TBB instead of OpenMP but I am getting the following errors every time:

```auto
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `omp_get_max_threads'
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `omp_get_num_threads'
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `GOMP_barrier'
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `GOMP_parallel'
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `omp_in_parallel'
    /usr/bin/ld: <PATH>/pytorch/build/lib/libtorch_cpu.so: undefined reference to `omp_get_thread_num'
    collect2: error: ld returned 1 exit status
    make[2]: *** [caffe2/CMakeFiles/kernel_function_legacy_test.dir/build.make:109: bin/kernel_function_legacy_test] Error 1

```

You can find the full log file [HERE](https://drive.google.com/file/d/1YXSicCUcDm2jZyY8n0al8EdJ9TbychWO/view?usp=sharing):

## To Reproduce

Steps to reproduce the behavior:

1. `git clone https://github.com/pytorch/pytorch`
2. `cd pytorch`
3. `ATEN_THREADING=TBB BUILD_BINARY=1 USE_EIGEN_THREADPOOL=1 USE_CUDA=0 PARALLEL_BACKEND=NATIVE_TBB USE_OPENMP=0 USE_TBB=1 MKL_THREADING=TBB BLAS=MKL USE_MKLDNN=1 MKLDNN_THREADING=TBB BUILD_BINARY=1 python setup.py build --cmake 2>&1 | tee ~/output.txt `

- PyTorch Version (e.g., 1.0): 1.10.0a0+git1798ff0
- OS (e.g., Linux): Manjaro
- How you installed PyTorch (`conda`, `pip`, source): pip
- Python version: 3.9.5
- CUDA/cuDNN version: NO
- GPU models and configuration: NO

---

<div class="post-metadata">

**Author:** ![Jackson\_Scott](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/jackson_scott/32/36702_2.png) [@Jackson\_Scott](https://discuss.pytorch.org/u/Jackson_Scott)\
**Post date:** [June 17, 2021, 3:12am UTC](https://discuss.pytorch.org/t/build-failed-with-tbb/123576/2 "2021-06-17T03:12:01Z")

</div>

Did you solve this issue? I am running into the same thing but with 1.5.1

---

<div class="post-metadata">

**Author:** ![Vlad\_Dumitru](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/vlad_dumitru/32/17919_2.png) [@Vlad\_Dumitru](https://discuss.pytorch.org/u/Vlad_Dumitru)\
**Post date:** [June 17, 2021, 9:52pm UTC](https://discuss.pytorch.org/t/build-failed-with-tbb/123576/3 "2021-06-17T21:52:41Z")

</div>

Yes I did, so far as I understood it was because of some flags for whatever reason. If I am running the fallowing command everything is working properly.

`BUILD_BINARY=1 USE_EIGEN_THREADPOOL=1 USE_CUDA=0 PARALLEL_BACKEND=NATIVE_TBB USE_OPENMP=0 USE_TBB=1 MKL_THREADING=TBB BLAS=MKL USE_MKLDNN=1 MKLDNN_THREADING=TBB BUILD_BINARY=1 python setup.py build --cmake 2>&1 | tee ~/output.txt `
