Skip to content

[caffe] Add new port#2848

Closed
willyd wants to merge 1 commit intomicrosoft:masterfrom
willyd:caffe
Closed

[caffe] Add new port#2848
willyd wants to merge 1 commit intomicrosoft:masterfrom
willyd:caffe

Conversation

@willyd
Copy link
Copy Markdown
Contributor

@willyd willyd commented Feb 21, 2018

WIP Do not merge. I am waiting for CI builds to pass on Caffe's side to update the github URLs in the portfile.

Alternative to PR #2570.

More features, based off caffe windows branch, dynamic and static linking should work (provided consuming projects use the /WHOLEARCHIVE flag)

New modular boost dependencies kindly provided by @cmpute.

@jasjuang @vlj your comments are welcome.

@willyd
Copy link
Copy Markdown
Contributor Author

willyd commented Feb 21, 2018

x64-windows-static build does not work with the opencv feature because patches failed to be applied (see #2762)

@cmpute
Copy link
Copy Markdown
Contributor

cmpute commented Feb 21, 2018

I found a bug here: https://github.com/willyd/caffe/blob/vcpkg/cmake/Cuda.cmake#L42

The output of the detect code can contains warning information like

c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h: warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(838): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(1772): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(2628): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(3477): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(4417): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(5319): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(6229): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(7104): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
c:\program files\nvidia gpu computing toolkit\cuda\v9.1\include\crt\math_functions.h(7914): warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
   Creating library a.lib and object a.exp
5.0

The last line is the expected version, however, the previous 9.1 will be fetched.

Edit regex from "([1-9].[0-9])" to "([1-9].[0-9])"$ will fix this.

@cmpute
Copy link
Copy Markdown
Contributor

cmpute commented Feb 21, 2018

Besides, generated *.exe should be copied into ${CURRENT_PACKAGES_DIR}/tools/caffe instead of ${CURRENT_PACKAGES_DIR}/tools imo, and vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/caffe) should be called after copying the executables

@willyd
Copy link
Copy Markdown
Contributor Author

willyd commented Feb 22, 2018

@cmpute Thanks for you comments I will have a look.

@cenit
Copy link
Copy Markdown
Contributor

cenit commented Feb 24, 2018

A big rework of OpenCV has been recently merged. Other work will come soon, but the first part maybe is enough for your x64-windows-static to be successful. Please let me know, I am very interested in a caffe working port here on vcpkg

@cmpute
Copy link
Copy Markdown
Contributor

cmpute commented Mar 4, 2018

@willyd Any update pls?

@jasjuang jasjuang mentioned this pull request Aug 9, 2018
@PhoebeHui PhoebeHui added the category:new-port The issue is requesting a new library to be added; consider making a PR! label Jan 22, 2019
@Cheney-W Cheney-W removed the category:new-port The issue is requesting a new library to be added; consider making a PR! label Mar 7, 2019
@Cheney-W
Copy link
Copy Markdown
Contributor

Cheney-W commented Mar 7, 2019

Here are the test results. The left results column is the latest commit to this PR, the right results column is test results from master: Blank space means the port did not exist.

Processing x64-linux                      585 vs 585
    caffe                                                       Fail vs 
Processing x64-osx                        577 vs 577
    caffe                                                       Fail vs  
Processing x64-windows                    856 vs 856
    caffe                                                       Fail vs 
Processing x64-windows-static             759 vs 759
    caffe                                                       Fail vs

BTW, please modify the control version in vcpkg/ports/caffe2/control file, because you modified the vcpkg/ports/caffe2/portfile.cmake file.

@cenit
Copy link
Copy Markdown
Contributor

cenit commented Mar 7, 2019

@Cheney-W instead of destroying the installed caffe2 installation, I would make them exclusive, blocking the installation in case the other is found.

@microsoft microsoft deleted a comment from azure-pipelines bot May 10, 2019
@cbezault
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@NancyLi1013
Copy link
Copy Markdown
Contributor

/azp run

Source: caffe
Version: 1.0.0
Build-Depends: boost-smart-ptr, boost-thread, boost-function, boost-date-time, boost-bind, boost-filesystem, boost-random, boost-math, boost-algorithm, gflags, glog, hdf5, protobuf, openblas
Description: Caffe: a fast open framework for deep learning.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please add Homepage here?

@@ -0,0 +1,92 @@
if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
message(FATAL_ERROR "Caffe cannot be built for the x86 architecture")
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we can use vcpkg_fail_port_install(ON_ARCH "x86") instead.

message(FATAL_ERROR "Caffe cannot be built for the x86 architecture")
endif()

include(vcpkg_common_functions)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

include(vcpkg_common_functions) is no longer needed.
Could you please remove this line?


vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO willyd/caffe
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this a fork repo?

set(USE_LEVELDB ON)
else()
set(USE_LEVELDB OFF)
endif()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As for these features, please use vcpkg_check_features() instead.

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)


file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/caffe RENAME copyright)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you update
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/caffe RENAME copyright)
as
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)?

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/caffe)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/caffe2)

# Remove caffe includes to avoid conflict with caffe port
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if (VCPKG_TARGET_ARCHITECTURE STREQUAL x86)
    message(FATAL_ERROR "Caffe2 cannot be built for the x86 architecture")
endif()

This can be replaced by vcpkg_fail_port_install(ON_ARCH "x86").

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please also remove include(vcpkg_common_functions) here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

vcpkg_apply_patches(
    SOURCE_PATH ${SOURCE_PATH}
    PATCHES
    ${CMAKE_CURRENT_LIST_DIR}/msvc-fixes.patch
)

This can be merged in

vcpkg_from_github(
   ...
   PATCHES msvc-fixes.patch
)


# Remove empty directories from include (should probably fix or
# patch caffe2 install script)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/caffe2/test)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

# Remove bin directory
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
    file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin)
endif()
# Remove bin directory
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
    file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()

These two parts can be merged to this:

if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
    file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please update

file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/caffe2)
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/caffe2 RENAME copyright)

as
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)?

@NancyLi1013
Copy link
Copy Markdown
Contributor

NancyLi1013 commented Jan 14, 2020

Hi @willyd thanks for this PR.
Could you please also update the version in ports/caffe2/CONTROLfile?

I also noticed that this port is forked different branch from that in PR #2570.

@NancyLi1013 NancyLi1013 changed the title Added caffe port [caffe] Add new port Jan 14, 2020
@dan-shaw
Copy link
Copy Markdown
Contributor

I’m going to close this PR because it’s been a long time since any update has been made. If this is something you’d like to see merged and work is being done, please reopen.

@dan-shaw dan-shaw closed this Jan 31, 2020
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.

10 participants