taichi-aot-demo
taichi-aot-demo copied to clipboard
How to tell CMake to use Anaconda environment?
When I add this to the CMake file:
execute_process (
COMMAND bash -c "which python"
OUTPUT_VARIABLE outVar
)
message(STATUS "path: ${outVar}")
I get the correct Python path for my current conda environment.
But, I am getting ModuleNotFoundError: No module named 'taichi' errors when running python ./ci/run_tests.py -l $TAICHI_C_API_INSTALL_DIR.
Someone met the same problem before and it seems old CMake's FindPython.cmake doesn't look for Python in conda environments. Please upgrade your CMake to 3.17 or higher.
That's interesting, I am using CMake 3.26.1, but it sounds like it could be a similar issue.
I couldn't find any info about how to possibly intervene with FindPython that might help here though https://cmake.org/cmake/help/latest/module/FindPython3.html
Maybe the 'someone' you mentioned might know? Or do you remember anything else about their issue/solution?
Ok, changing this to 3.26 fixed it! Is that what you meant?
https://github.com/taichi-dev/taichi-aot-demo/blob/a6c35b6a8b1cc17768bc66ed628c2b44cf889bf7/CMakeLists.txt#L1
Ok, so to run the CI script on macOS using conda and Vulkan only, I had to:
- Change this to 3.26 https://github.com/taichi-dev/taichi-aot-demo/blob/a6c35b6a8b1cc17768bc66ed628c2b44cf889bf7/CMakeLists.txt#L1
- In
test_config.jsonchange cmake_args to"cmake_args" : ["-DTI_WITH_CUDA=OFF", "-DTI_WITH_CPU=OFF", "-DMY-PYTHON-VERSION=[insert_conda_python_version]"] - Comment out this block https://github.com/taichi-dev/taichi-aot-demo/blob/a6c35b6a8b1cc17768bc66ed628c2b44cf889bf7/framework/CMakeLists.txt#L85 (ref #125)
- Add this to all CMakeFiles in each demo folder otherwise CMake will find the wrong Python:
set(CMAKE_PREFIX_PATH "/Users/xxx/.miniconda3/envs/my-env/")
find_package (Python ${MY_PYTHON_VERSION} EXACT REQUIRED)
- Add
set(CMAKE_PREFIX_PATH "/Users/xxx/.miniconda3/envs/my-env/")to the root CMakeFile as well.