-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Install] Fix error during python/tvm installation #17808
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
Conversation
|
cc @tqchen |
|
@vacu9708 Thanks. |
|
@mshr-h Your opinion makes sense. Overwriting instead of skipping would be the correct modification. I'll make the change shortly. |
c3ab192 to
b0536d1
Compare
b9d1b67 to
8482117
Compare
cchung100m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks to @vacu9708 😄
|
@mshr-h can you confirm if the patch fixes your error? |
|
Still fails... Here's my repro. $ python3 -m venv .venv
$ source .venv/bin/activate
$ pip3 install cmake ninja setuptools cython
$ cmake -S . -B build -G Ninja
$ cmake --build build
$ cp build/libtvm_runtime.so python/tvm/ # copy the shared library to raise shutil.SameFileError
$ cd python
$ python3 setup.py develop
Use git describe based version 0.20.dev158+gbf6121656
Traceback (most recent call last):
File "/home/ubuntu/data/project/tvm_work/tvm/python/setup.py", line 197, in <module>
shutil.copy(path, os.path.join(CURRENT_DIR, "tvm"))
File "/usr/lib/python3.12/shutil.py", line 435, in copy
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "/usr/lib/python3.12/shutil.py", line 240, in copyfile
raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/ubuntu/data/project/tvm_work/tvm/python/tvm/libtvm_runtime.so' and '/home/ubuntu/data/project/tvm_work/tvm/python/tvm/libtvm_runtime.so' are the same file |
|
@mshr-h |
|
It’s probably due to the search priority of Changin from this # Pip lib directory
dll_path.append(os.path.join(ffi_dir, ".."))
# Default cmake build directory
dll_path.append(os.path.join(source_dir, "build"))
dll_path.append(os.path.join(source_dir, "build", "Release"))
# Default make build directory
dll_path.append(os.path.join(source_dir, "lib"))to this (prioritize build directory over pip lib directory) # Default cmake build directory
dll_path.append(os.path.join(source_dir, "build"))
dll_path.append(os.path.join(source_dir, "build", "Release"))
# Default make build directory
dll_path.append(os.path.join(source_dir, "lib"))
# Pip lib directory
dll_path.append(os.path.join(ffi_dir, "..")) |
|
@mshr-h Thank you for your analysis.
In my opinion:
|
95061f2 to
5f40155
Compare
mshr-h
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me. Just minor changes are needed.
This PR fixes a bug where running "pip install -e /path-to-tvm/python" fails if installation files remain in python/tvm. The fix includes: - Preventing libraries from `python/tvm` from being appended to the library list, resolving the shutil.SameFileError exception raised by shutil.copy() - Adding cleanup logic earlier in case it was not executed due to a previous pip installation failure, resolving the FileExistsError exception raised by shutil.copytree()
|
Thanks a lot! @vacu9708 |
This PR fixes a bug where running "pip install -e /path-to-tvm/python" fails if installation files remain in python/tvm. The fix includes: - Preventing libraries from `python/tvm` from being appended to the library list, resolving the shutil.SameFileError exception raised by shutil.copy() - Adding cleanup logic earlier in case it was not executed due to a previous pip installation failure, resolving the FileExistsError exception raised by shutil.copytree()
Expected behavior
"pip install -e /path-to-tvm/python" successfully installs the TVM package as documented on https://tvm.apache.org/docs/install/from_source.html#
Issue
If "libtvm.so" and "libtvm_runtime.so" remain in "python/tvm" for some reason,If a previous pip installation was unsuccessful and the cleanup was not performed, running "pip install -e /path-to-tvm/python" fails because shutil.copy() and shutil.copytree() raise exceptions due to the remaining temporary files.
How I encountered the issue
I ran "pip install" without "sudo" first, and it failed without "sudo". (probably because I was not in a virtual environment)
Here the cleanup code couldn't be executed
Error log