-
Notifications
You must be signed in to change notification settings - Fork 621
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
support for ZSTD compression for TIFF files #2273
Conversation
@kindoblue - thank you for your contribution.
|
db0459b
to
b87d76c
Compare
To generate tiff files compressed with ZSTD I used the python library tifffile For example you can do: img_a = cv2.imread("lena_std.tif", cv2.IMREAD_COLOR)
im_rgb = cv2.cvtColor(img_a, cv2.COLOR_BGR2RGB)
tifffile.imwrite("lena_std.zstd.tif", im_rgb, compress='ZSTD') I actually use tifffile to create multichannel TIFFs from NumPy arrays. |
Thanks! I will create some additional test data soon. |
@kindoblue - can you check if NVIDIA/DALI_extra#46 does what you need? |
The RB channels in the picture are swapped. The bps value reported by the |
@kindoblue - I have fixed the channels. Should be fine now. |
I can create a pipeline and load the picture. I am taking a look at the gtest suite but even if I run those tests, dali and the operators will run on the deps I have installed on my machine, not from the packaged wheel, right? But anyway, regarding that particular TIFF file, I tested it manually. |
RUN ZSTANDARD_VERSION=1.4.5 && \ | ||
curl -L https://github.com/facebook/zstd/releases/download/v${ZSTANDARD_VERSION}/zstd-${ZSTANDARD_VERSION}.tar.gz | tar -xzf - && \ | ||
cd zstd-${ZSTANDARD_VERSION} && \ | ||
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install 2>&1 >/dev/null && \ |
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.
You need to cross compile it for aarch64, see how other libraries are build.
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.
I was taking a look at QNX, I didn't even manage to understand which toolchain is good for Linux. Any pointer? I did some programming on embedded platforms in the past but never with QNX.
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.
I guess it should be something like this:
CFLAGS="-fPIC" \
CXXFLAGS="-fPIC" \
CC=aarch64-unknown-nto-qnx7.0.0-gcc \
CXX=aarch64-unknown-nto-qnx7.0.0-g+ \
prefix=/usr/aarch64-unknown-nto-qnx/aarch64l \
make install -j"$(grep ^processor /proc/cpuinfo | wc -l)" && \
And similar (check how other deps are build there) for aarch64.
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.
And regarding the aarch64 for Nvidia Jetson, the SDKManager doesn't allow the download for ubuntu 20.04 :-(
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.
Sorry, I cannot do much about it.
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.
I'm trying to get a temp license for qnx and test the compilation on that platform. Regarding the aarch64 for nvidia jetson, I will see in the coming days to use a box with ubuntu 18.04 installed
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.
Great!.
Thanks.
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.
So I managed to install on my host (ubuntu 20.04) qnx 7.1 and I tried to compile the zstd library. As I cannot use the SDKManager I could not test the docker build but I think the modifications I did in the last commits should work. On my host the zstd library is correctly compiled and linked
lib file libzstd.so.1.4.6
libzstd.so.1.4.6: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, BuildID[md5/uuid]=e96f8cf465e8cec436c1487611392dc9, with debug_info, not stripped
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.
Sure, let me try it on our CI.
# zstandard compression library | ||
RUN ZSTANDARD_VERSION=1.4.5 && \ | ||
curl -L https://github.com/facebook/zstd/releases/download/v${ZSTANDARD_VERSION}/zstd-${ZSTANDARD_VERSION}.tar.gz | tar -xzf - && \ | ||
cd zstd-${ZSTANDARD_VERSION} && \ |
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.
You need to cross compile it for aarch64, see how other libraries are build.
Please build the DALI wheel - https://docs.nvidia.com/deeplearning/dali/user-guide/docs/compilation.html#compiling-dali-from-source-using-docker-builder-recommended, install it on your host system (the wheel uses own, not system one dependencies) and then run the test from the place where the wheel has been installed |
I managed to run the tests withing the virtualenv, after having compiled the wheel. I used your DALI_extra branch: ➜ DALI_extra git:(more_tifs) ✗ git status
On branch more_tifs
Your branch is up to date with 'origin/more_tifs'. These are the test results (not sure if the ZSTD tiff would be automatically included in the tests): (deep) ➜ test ./dali_core_test.bin
[==========] 269 tests from 50 test suites ran. (2955 ms total)
[ PASSED ] 269 tests.
YOU HAVE 4 DISABLED TESTS
(deep) ➜ test ./dali_test.bin
[==========] 358 tests from 80 test suites ran. (14851 ms total)
[ PASSED ] 356 tests.
[ SKIPPED ] 2 tests, listed below:
[ SKIPPED ] CApiTest/0.ExternalSourceSingleAllocDifferentBackendsTest
[ SKIPPED ] CApiTest/0.ExternalSourceMultipleAllocDifferentBackendsTest
YOU HAVE 5 DISABLED TESTS
(deep) ➜ test ./dali_kernel_test.bin
[==========] 1594 tests from 412 test suites ran. (68384 ms total)
[ PASSED ] 1594 tests.
YOU HAVE 2 DISABLED TESTS
(deep) ➜ test ./dali_operator_test.bin
[==========] 4753 tests from 222 test suites ran. (312595 ms total)
[ PASSED ] 4748 tests.
[ SKIPPED ] 1 test, listed below:
[ SKIPPED ] HwDecoderUtilizationTest.UtilizationTest
[ FAILED ] 4 tests, listed below:
[ FAILED ] VideoReaderTest.FrameLabels
[ FAILED ] VideoReaderTest.FrameLabelsWithFileListFrameNum
[ FAILED ] VideoReaderTest.TimestampLabels
[ FAILED ] VideoReaderTest.StartEndLabels
4 FAILED TESTS
YOU HAVE 4 DISABLED TESTS |
Test results looks good, please update aarch and qnx deps dockers, rebase your PR and update DALI_EXTRA_VESRION content to |
Signed-off-by: Stefano <kindoblue@gmail.com>
b87d76c
to
4edde4e
Compare
Signed-off-by: Stefano <kindoblue@gmail.com>
4edde4e
to
03ac616
Compare
CI MESSAGE: [1641658]: BUILD STARTED |
CI MESSAGE: [1641688]: BUILD STARTED |
CI MESSAGE: [1641786]: BUILD STARTED |
5135ee3
to
b0816a3
Compare
curl -L https://github.com/facebook/zstd/releases/download/v${ZSTANDARD_VERSION}/zstd-${ZSTANDARD_VERSION}.tar.gz | tar -xzf - && \ | ||
cd zstd-${ZSTANDARD_VERSION} && \ | ||
CFLAGS="-fPIC" CXXFLAGS="-fPIC" CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ \ | ||
make -j"$(grep ^processor /proc/cpuinfo | wc -l)" install DESTDIR=/usr/aarch64-linux-gnu/ 2>&1 >/dev/null && \ |
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.
It would be better to use prefix
instead of DESTDIR
as now it would install in
/usr/aarch64-linux-gnu/usr/local/...
.
I have also noticed that tiff build cmd needs to be updated, CFLAGS and CXXFLAGS need to be set to "-fPIC -I/usr/aarch64-unknown-nto-qnx/aarch64le/include"
to include a new dependency.
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.
You are right, DESTDIR and prefix have different behaviour. Regarding the flag for the tiff library, I am afraid you need to use the configure flag --with-zstd-include-dir
and --with-zstd-lib-dir
and not the -I
because that, I tested on my host, doesn't work. Anyway I will make the modification later on
Or perhaps, once changed from DESTDIR to prefix, the zstd will be found because now the prefix dir would be correct.
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.
I did the modification only for the prefix. I think it should work then. Sorry for that, but I am working in the dark :-)
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.
Sure, no problem. We really appreciate your time and patience.
Or perhaps, once changed from DESTDIR to prefix, the zstd will be found because now the prefix dir would be correct.
I think it won't work just like that as configure searches the default system directories, not the one we use in the prefix.
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.
Checked on my host. You are again right. I will use the --with-zstd--
flags
CI MESSAGE: [1641786]: BUILD FAILED |
b0816a3
to
d11d42b
Compare
Signed-off-by: Stefano <kindoblue@gmail.com>
d11d42b
to
3be9658
Compare
CI MESSAGE: [1641688]: BUILD FAILED |
CI MESSAGE: [1644611]: BUILD STARTED |
CI MESSAGE: [1644611]: BUILD FAILED |
CI MESSAGE: [1644772]: BUILD STARTED |
CI MESSAGE: [1647820]: BUILD STARTED |
CI MESSAGE: [1647820]: BUILD FAILED |
CI MESSAGE: [1647899]: BUILD STARTED |
CI MESSAGE: [1647899]: BUILD FAILED |
324f9fc
to
d2d1904
Compare
CI MESSAGE: [1647951]: BUILD STARTED |
CI MESSAGE: [1647951]: BUILD FAILED |
d2d1904
to
c090563
Compare
CI MESSAGE: [1648052]: BUILD STARTED |
CI MESSAGE: [1648052]: BUILD PASSED |
cd /tmp && \ | ||
curl -L https://github.com/madler/zlib/archive/v${LIBZ_VERSION}.tar.gz | tar -xzf - && \ | ||
cd zlib-${LIBZ_VERSION} && \ | ||
./configure --prefix=/usr/local && \ |
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.
Don't we need PIC here as well?
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.
Added
c090563
to
5256982
Compare
CI MESSAGE: [1649140]: BUILD STARTED |
CI MESSAGE: [1649140]: BUILD FAILED |
5256982
to
4277b6e
Compare
CI MESSAGE: [1649201]: BUILD STARTED |
CI MESSAGE: [1649201]: BUILD FAILED |
CI MESSAGE: [1649201]: BUILD PASSED |
@@ -2643,3 +2643,70 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
POSSIBILITY OF SUCH DAMAGE. | |||
|
|||
======================== | |||
|
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.
I think we should say here that this is for zstd. @JanuszL ?
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.
Done
Signed-off-by: Janusz Lisiecki <jlisiecki@nvidia.com>
CI MESSAGE: [1650977]: BUILD STARTED |
CI MESSAGE: [1650977]: BUILD PASSED |
@kindoblue - thank you for your contribution! |
Thanks to you guys! |
Why we need this PR?
What happened in this PR?
builds libzstd and libz and adds it as a wheel dependency
ImageDecoder operator, in case a TIFF file is opened
N/A
currente tests with new test TIFF file added in Adds TIFF image with ZSTD encoding DALI_extra#46
N/A
JIRA TASK: NA