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

Implement Cache and __cuda_array_interface__ for v21.06.00 #48

Merged
merged 16 commits into from
Jun 8, 2021

Conversation

gigony
Copy link
Contributor

@gigony gigony commented Jun 5, 2021

I'm sorry for this big change.
This includes CI build failure fixes as well as new features/fixes/documents that couldn't be merged due to CI build failures.

@quasiben on top of your change (#46), the only missing piece was, adding pytest (8334f1f) (which was not revealed until I added set -x to the build script (fae529d).

@jakirkham This change doesn't include a doc builder change in your PR (
https://github.com/rapidsai/cucim/pull/45/files#diff-5ed0e3039eb400d13dc55579a034925ea8d08e9f2054085b1c79fdc46a7c09a8L29) so the script may need to further updated in the next change.

@gigony gigony added bug Something isn't working doc Improvements or additions to documentation feature request New feature or request improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Jun 5, 2021
@gigony gigony requested review from quasiben and jakirkham June 5, 2021 11:08
@gigony gigony requested review from a team as code owners June 5, 2021 11:08
@gigony gigony changed the base branch from branch-21.08 to branch-21.06 June 5, 2021 11:10
@gigony gigony changed the title Implement Cache and __cuda_array_interface__ Implement Cache and __cuda_array_interface__ for v21.06.00 Jun 5, 2021
@gigony gigony removed bug Something isn't working doc Improvements or additions to documentation improvement Improves an existing functionality labels Jun 5, 2021
@gigony
Copy link
Contributor Author

gigony commented Jun 7, 2021

Hi @ajschmidt8, could this change be merged into 21.06.00 branch before the release (#47)?

@gigony gigony mentioned this pull request Jun 7, 2021
@@ -49,14 +44,13 @@ def read(*names, **kwargs):
url='https://github.com/rapidsai/cucim',
packages=find_packages('src'),
package_dir={'cucim': 'src/cucim'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
# # https://docs.python.org/3/distutils/setupscript.html
Copy link
Member

Choose a reason for hiding this comment

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

Any reason to leave these comments here instead of removing ?

Same question for the package_data= commented code below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, no specific reason. Just for future reference. Will remove it. Thank you for pointing out that!

@quasiben
Copy link
Member

quasiben commented Jun 7, 2021

I found it easier to look at the individual commits. I left a few small comments on the setup.py file. I think there is something probably better to do than add the pytest conda package but i'm ok pushing that off for another PR

Copy link
Member

@jakirkham jakirkham left a comment

Choose a reason for hiding this comment

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

Thanks Gigon! 😄

Had some questions below

Comment on lines 117 to 134
# count = 0
# for h in range(start_location, height, tile_size):
# for w in range(start_location, width, tile_size):
# count += 1
# start_loc_iter = ((w, h)
# for h in range(start_location, height, tile_size)
# for w in range(start_location, width, tile_size))
# with Timer(" Thread elapsed time (OpenSlide)") as timer:
# with concurrent.futures.ThreadPoolExecutor(
# max_workers=num_workers
# ) as executor:
# executor.map(
# lambda start_loc: load_tile_openslide(
# slide, start_loc, tile_size),
# start_loc_iter,
# )
# openslide_time = timer.elapsed_time()
# openslide_tot_time += openslide_time
Copy link
Member

Choose a reason for hiding this comment

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

Why is this commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my bad. changed the code during the local testing. Will revert it. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

All good. Thanks Gigon! 😄

Comment on lines 151 to 152
# print(" Performance gain (OpenSlide/cuCIM): {}".format(
# openslide_time / cucim_time))
Copy link
Member

Choose a reason for hiding this comment

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

Same question here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will revert it.

python/cucim/setup.cfg Show resolved Hide resolved
@@ -77,13 +79,13 @@ gpuci_conda_retry build -c ${LIBCUCIM_BLD_PATH} -c conda-forge -c rapidsai-night

# Install cuCIM and its dependencies
gpuci_logger "Installing cuCIM and its dependencies"
gpuci_conda_retry install -y -c ${LIBCUCIM_BLD_PATH} -c ${CUCIM_BLD_PATH} \
"rapids-build-env=$MINOR_VERSION.*" \
Copy link
Member

Choose a reason for hiding this comment

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

Why did this get dropped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that there is no rapids-build-env package whose version is $MINOR_VERSION.* as we switched to CalVer.

https://anaconda.org/rapidsai/rapids-build-env/files

Copy link
Member

Choose a reason for hiding this comment

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

@gigony, this will need to be re-added. We use the rapidsai-nightly conda channel for pre-release packaging. You can find the cal-ver packages here: https://anaconda.org/rapidsai-nightly/rapids-build-env/files

Copy link
Member

Choose a reason for hiding this comment

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

Somewhat related. I think we are missing an activate line (this is probably my fault). Was trying to fix that here ( 495aa73 ). Think we may need to add that as well

#include "cucim/core/framework.h"

Copy link
Member

Choose a reason for hiding this comment

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

nit: Could we drop this blank line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Will remove it.

@@ -74,4 +68,53 @@ void get_pointer_attributes(PointerAttributes& attr, const void* ptr)
}
}

bool move_raster_from_host(void** target, size_t size, cucim::io::Device& dst_device)
Copy link
Member

Choose a reason for hiding this comment

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

Can device be const?

Suggested change
bool move_raster_from_host(void** target, size_t size, cucim::io::Device& dst_device)
bool move_raster_from_host(void** target, size_t size, const cucim::io::Device& dst_device)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should be const. Will update it.

return true;
}

bool move_raster_from_device(void** target, size_t size, cucim::io::Device& dst_device)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool move_raster_from_device(void** target, size_t size, cucim::io::Device& dst_device)
bool move_raster_from_device(void** target, size_t size, const cucim::io::Device& dst_device)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it should be const. Will update it.

Comment on lines 34 to +35
version=read('VERSION').strip(), # versioneer.get_version(),
# cmdclass=versioneer.get_cmdclass()
cmdclass=versioneer.get_cmdclass(),
Copy link
Member

Choose a reason for hiding this comment

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

If we are using versioneer for cmdclass, should we use for version as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In case of versioneer, version comes from git tags, but C++ code's build system currently requires version as VERSION file.
I can try to refactor C++ code builder to get the version from git tags later (https://ipenguin.ws/2012/11/cmake-automatically-use-git-tags-as.html) but the current VERSION file seems okay to me.

Currently, version number from versioneer is used only when CuPy with scikit-image is available (#44, 818dc2f#diff-80a85bd6c52ce89c0dc59a606ca1205a2673c20ff860c65a3964db51ffa64ec8R47)

Comment on lines +34 to +41
# Try to import cupy first.
# If cucim.clara package is imported first, you may see the following error when running on CUDA 10.x (#44)
# python3: Relink `/usr/lib/x86_64-linux-gnu/libnccl.so.2.8.3' with `/lib/x86_64-linux-gnu/librt.so.1' for IFUNC symbol `clock_gettime'
# Segmentation fault
try:
import cupy
except ImportError:
pass
Copy link
Member

Choose a reason for hiding this comment

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

Interesting. Do we know why that is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't know the exact root cause, but I guess,

This change is related to #44

If the system has only CUDA 10.x library, since cucim.clara part of the library depends on CUDA 11 and different version of runtime, it looks that it can conflict with symbols CUDA-based library that depends on CUDA 10.X

You can see version-related issues from other Github issue:
tensorflow/tensorflow#19375

Comment on lines 112 to 113
for num_workers in range(1, num_threads + 1):
for num_workers in (num_threads,): # range(1, num_threads + 1):
Copy link
Member

Choose a reason for hiding this comment

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

Why is this commented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is modified during the local test (since I didn't want to execute it for all available thread # configurations.)
Reverted it.

@gigony
Copy link
Contributor Author

gigony commented Jun 7, 2021

Thanks @jakirkham and @quasiben for the review! I would address your comments tonight.

Copy link
Member

@ajschmidt8 ajschmidt8 left a comment

Choose a reason for hiding this comment

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

Few changes requested here. Also, branch-21.06 is in code-freeze, so the base branch for this PR will need to be updated to branch-21.08.

@@ -77,13 +79,13 @@ gpuci_conda_retry build -c ${LIBCUCIM_BLD_PATH} -c conda-forge -c rapidsai-night

# Install cuCIM and its dependencies
gpuci_logger "Installing cuCIM and its dependencies"
gpuci_conda_retry install -y -c ${LIBCUCIM_BLD_PATH} -c ${CUCIM_BLD_PATH} \
"rapids-build-env=$MINOR_VERSION.*" \
Copy link
Member

Choose a reason for hiding this comment

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

@gigony, this will need to be re-added. We use the rapidsai-nightly conda channel for pre-release packaging. You can find the cal-ver packages here: https://anaconda.org/rapidsai-nightly/rapids-build-env/files

CHANGELOG.md Outdated
@@ -1,4 +1,4 @@
# cuCIM 21.06.00 (Date TBD)
# cuCIM [21.06.00](https://github.com/rapidsai/cucim/wiki/release_notes_v21.06.00) (Date TBD)
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with the changelogs of other RAPIDS libraries, this change should probably be removed. Also, we have a script that updates the changelog during each release, so it would overwrite this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. Will remove it from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And for the following change, will try to read rapids-build-env with rapidsai-nightly version.

gpuci_conda_retry install -y -c ${LIBCUCIM_BLD_PATH} -c ${CUCIM_BLD_PATH} \
"rapids-build-env=$MINOR_VERSION.*" \

@quasiben
Copy link
Member

quasiben commented Jun 7, 2021

Few changes requested here. Also, branch-21.06 is in code-freeze, so the base branch for this PR will need to be updated to branch-21.08.

For clarity, we'd like for this to be released with 21.06 as other libraries would like to pick this up -- but not part of the larger RAPIDS integration meta-package. Is that something we could do ?

@ajschmidt8
Copy link
Member

Few changes requested here. Also, branch-21.06 is in code-freeze, so the base branch for this PR will need to be updated to branch-21.08.

For clarity, we'd like for this to be released with 21.06 as other libraries would like to pick this up -- but not part of the larger RAPIDS integration meta-package. Is that something we could do ?

@quasiben, gotcha. This PR has a lot of changes, so I'm not sure it'd be a good idea to merge all of this a few days before the release. Couple questions here though.

  1. Which libraries require these changes?
  2. Are the changes here considered "required" for 21.06 to work? Or are they just "nice-to-haves"?

@jakirkham
Copy link
Member

jakirkham commented Jun 7, 2021

Several of these changes were in previous PRs that were blocked due to CI issues. So Gigon has aggregated them together. IOW they are not as new as they might seem

The changes are really limited to cuCIM and are mainly in response to needs Clara has in their downstream libraries or outside user requests. So they shouldn't affect other RAPIDS libraries

@quasiben
Copy link
Member

quasiben commented Jun 7, 2021

@gigony would be better positioned to answer these questions:

  1. Which libraries require these changes?
    a. MONAI is a higher lever product depending on
  2. Are the changes here considered "required" for 21.06 to work? Or are they just "nice-to-haves"?
    a. The majority of these changes are in the required for 21.06. I would hope these large code changes before releases decreases as the library matures.

Again, @gigony can you also comment here ?

@gigony
Copy link
Contributor Author

gigony commented Jun 7, 2021 via email

@raydouglass
Copy link
Member

raydouglass commented Jun 7, 2021

I think this is fine to merge this into 21.06 after addressing some of the requested changes.

@quasiben
Copy link
Member

quasiben commented Jun 7, 2021

Thanks @raydouglass

@gigony
Copy link
Contributor Author

gigony commented Jun 8, 2021

Thank you @quasiben @jakirkham @ajschmidt8 for the review!

I have addressed your comments except #48 (comment) to make sure that this change is buildable without errors.

Could we merge this PR first and then apply @jakirkham 's patches shown below, to use rapids conda environment?

@ajschmidt8 ajschmidt8 merged commit 45cf987 into rapidsai:branch-21.06 Jun 8, 2021
This was referenced Jun 8, 2021
rapids-bot bot pushed a commit that referenced this pull request Jul 27, 2021
`__array_interface__` for the object returned by `CuImage.associated_image()` was missing so cannot be converted numpy.

This bug was introduced during the implementation of Cache and support for `__cuda_array_interface__`: #48 .

`associated_image()` API is not frequently used by users so it's fine.

We will need to add a test case for this once the artificial test image with the associated image (such as Philips TIFF) is available.

Authors:
  - Gigon Bae (https://github.com/gigony)

Approvers:
  - https://github.com/jakirkham

URL: #65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants