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

Fix creating tensor from copy of numpy array warning messages #2170

Merged
merged 2 commits into from
Jun 21, 2022

Conversation

arnavgarg1
Copy link
Contributor

This PR is created for the following issue.

PyTorch wants us to create a tensor for input and output features from a copy of the numpy array instead of directly using the numpy array. This typically results in the following error message:

UserWarning: The given NumPy array is not writable, and PyTorch does not support non-writable tensors. This means writing to this tensor will result in undefined behavior. You may want to copy the array to protect its data or make it writable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at  /root/pytorch/torch/csrc/utils/tensor_numpy.cpp:172.)

This PR should fix this everywhere within Ludwig.

@arnavgarg1 arnavgarg1 added the productivity and code quality Engineer productivity, maintainability, consistency, readability label Jun 21, 2022
@arnavgarg1 arnavgarg1 self-assigned this Jun 21, 2022
@arnavgarg1 arnavgarg1 linked an issue Jun 21, 2022 that may be closed by this pull request
@arnavgarg1 arnavgarg1 removed the productivity and code quality Engineer productivity, maintainability, consistency, readability label Jun 21, 2022
@arnavgarg1 arnavgarg1 marked this pull request as draft June 21, 2022 07:39
@github-actions
Copy link

github-actions bot commented Jun 21, 2022

Unit Test Results

       6 files  ±0         6 suites  ±0   2h 13m 50s ⏱️ - 9m 1s
2 828 tests ±0  2 794 ✔️ ±0    34 💤 ±0  0 ±0 
8 484 runs  ±0  8 378 ✔️ ±0  106 💤 ±0  0 ±0 

Results for commit ddc1c74. ± Comparison against base commit af4b102.

♻️ This comment has been updated with latest results.

@arnavgarg1 arnavgarg1 marked this pull request as ready for review June 21, 2022 08:57
@arnavgarg1 arnavgarg1 merged commit 3fca056 into master Jun 21, 2022
@arnavgarg1 arnavgarg1 deleted the 2169-cleanup-numpy-array-not-writeable-errors branch June 21, 2022 18:26
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.

Cleanup NumPy array not writeable errors
2 participants