-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
The aws sdk and libtorch build failed #2808
Comments
how are you installing the SDK? this error to me indicates that you have drift in your installation where you are including a header that expects these functions to be present but are using a binary where they are not present. Those specific functions were added in a 1.10 version a while ago. My guess if you clean installed the SDK install to a specific directory, you would not see this problem
also just for clarity this is not the linking stage of our project, this is during the linking of your build when |
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one. |
Build S3 part of aws-sdk-cpp: http_predict/downLoad.cpp example code: // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#include "torch/torch.h"
#include "torch/script.h"
#include <iostream>
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <fstream>
#include "s3download.h"
bool AwsDoc::S3::GetObject(const Aws::String &objectKey,
const Aws::String &fromBucket,
const Aws::Client::ClientConfiguration &clientConfig) {
Aws::S3::S3Client client(clientConfig);
Aws::S3::Model::GetObjectRequest request;
request.SetBucket(fromBucket);
request.SetKey(objectKey);
Aws::S3::Model::GetObjectOutcome outcome =
client.GetObject(request);
if (!outcome.IsSuccess()) {
const Aws::S3::S3Error &err = outcome.GetError();
std::cerr << "Error: GetObject: " <<
err.GetExceptionName() << ": " << err.GetMessage() << std::endl;
}
else {
std::cout << "Successfully retrieved '" << objectKey << "' from '"
<< fromBucket << "'." << std::endl;
}
return outcome.IsSuccess();
}
#ifndef TESTING_BUILD
int main() {
Aws::SDKOptions options;
Aws::InitAPI(options);
{
//TODO(user): Change bucketName to the name of a bucket in your account.
const Aws::String bucketName = "<Enter bucket name>";
//TODO(user): Change objectName to the name of an object in the bucket.
//See create_bucket.cpp and put_object.cpp to create a bucket and load an object into that bucket.
const Aws::String objectName = "<Enter object name>";
Aws::Client::ClientConfiguration clientConfig;
// Optional: Set to the AWS Region in which the bucket was created (overrides config file).
// clientConfig.region = "us-east-1";
AwsDoc::S3::GetObject(objectName, bucketName, clientConfig);
}
Aws::ShutdownAPI(options);
return 0;
}
#endif // TESTING_BUILD s3download.h: #include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/BucketLocationConstraint.h>
namespace AwsDoc {
namespace S3 {
bool GetObject(const Aws::String &objectKey,
const Aws::String &fromBucket,
const Aws::Client::ClientConfiguration &clientConfig);
extern std::mutex upload_mutex;
extern std::condition_variable upload_variable;
} // namespace S3
} // namespace AwsDoc |
Can you please clean your build and install folders and then try rebuilding this sdk? |
@jmklix I made sure to build both libtorch and the AWS C++ SDK in Debug mode. By any chance, does anyone have any ideas on what could be causing this? I also tried looking for conflicting symbols in libtorch by using the Operating SystemUbuntu 20.04.5 LTS Compiler Version usedUbuntu 9.4.0-1ubuntu1~20.04.2 AWS SDK VersionAWS CPP SDK - 1.11.361 Libtorch Build Version2.5.0.dev20240701+cpu CMakeLists.txtcmake_minimum_required(VERSION 3.13)
project(example-app)
set(CMAKE_CXX_STANDARD 20)
# set(CMAKE_BUILD_TYPE Debug)
include(CTest)
if(NOT BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
# Set the path to the AWS SDK and other libraries
# set(AWS_SDK_PATH "/home/davidn/aws-sdk-cpp/build/AWSSDK")
set(AWS_SDK_PATH "/home/davidn/ml-c++/libs/aws-sdk-cpp-out-debug")
set(LIBTORCH_PATH "$ENV{HOME}/ml-c++/libs/libtorch-debug")
# Set CMAKE_MODULE_PATH to help find the custom AWS SDK
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${AWS_SDK_PATH}/lib/cmake/AWSSDK")
set(CMAKE_PREFIX_PATH ${AWS_SDK_PATH} ${LIBTORCH_PATH})
# Ensure CMake uses the custom path for AWS SDK
set(AWSSDK_ROOT_DIR ${AWS_SDK_PATH})
set(AWSSDK_INCLUDE_DIR ${AWS_SDK_PATH}/include)
set(AWSSDK_LIB_DIR ${AWS_SDK_PATH}/lib)
# Find AWS SDK
find_package(AWSSDK REQUIRED COMPONENTS s3-crt HINTS ${AWS_SDK_PATH} NO_DEFAULT_PATH)
# Find other required packages
find_package(Torch REQUIRED)
find_package(CURL)
# Add RapidJSON
add_library(rapidjson INTERFACE)
target_include_directories(rapidjson INTERFACE
$ENV{HOME}/autolabel-anything-c++/libs/rapidjson/include
)
file(GLOB AWSDOC_S3CRT_HEADERS
"include/awsdoc/s3-crt/*.h"
)
add_executable("test1" "s3-crt-demo.cpp" "wavreader.c" ${AWSDOC_S3CRT_HEADERS})
# Include directories
target_include_directories("test1" PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$ENV{HOME}/ml-c++/libs/LibrosaCpp/librosa/eigen3/Eigen
$ENV{HOME}/ml-c++/libs/LibrosaCpp
)
# Link libraries
target_link_libraries("test1"
PRIVATE
# ${TORCH_LIBRARIES}
${AWSSDK_LINK_LIBRARIES}
${AWSSDK_LIBRARIES}
rapidjson
CURL::libcurl
)
# Set verbose output
set(CMAKE_VERBOSE_MAKEFILE ON)
# Print AWS SDK details
message(STATUS "AWSSDK_FOUND: ${AWSSDK_FOUND}")
message(STATUS "AWSSDK_INCLUDE_DIRS: ${AWSSDK_INCLUDE_DIRS}")
message(STATUS "AWSSDK_LIBRARIES: ${AWSSDK_LIBRARIES}")
# Print all variables
# get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
Error outputThe error is the following:
Upon deleting all files in the build directory and running Output:
|
I also get the same error with a fresh install of the AWS C++ SDK using S3 only instead of S3-CRT as done previously. |
@cl1218 Did you ever resolve this? |
I also just tried it out with an older version of the AWS C++ SDK, namely tag 1.11.234. I unfortunately still run into the same issue. |
Hi @DavidEnriqueNieves
I can see it quite deviates from our example app cmake script and our local test app within the main repo. I'm not entirely sure why you are manually setting certain cmake variables (such as AWSSDK_ROOT_DIR, AWSSDK_INCLUDE_DIR, AWSSDK_LIB_DIR). I can also see that both CMAKE_PREFIX_PATH and CMAKE_MODULE_PATH are set with the SDK install path. Typically we recommend setting only the CMAKE_PREFIX_PATH to contain an install path of the SDK, and then calling
I'm not sure what will happen if the SDK install path is pushed into different cmake package/library search variables, as well as manually set AWSSDK_LIB_DIR. Please let us know if there is a specific reason for your approach and you would have any suggestion what to update in our cmake script. |
Well, I tried this out with the example CMakeLists.txt file that you linked from here. My reasoning for manually setting the directories was to isolate and ensure that only the directories that I was pointing it to were used for linking the libraries. However, it seems that this approach was flawed due to some unforeseen details. I still don't fully understand everything that's going on under the hood with CMake, but I suppose that's for me to find out. For anyone who needs reference, this CMakeLists.txt file worked for me:
Thank you for your suggestion. |
@DavidEnriqueNieves I glade that you were able to get it working. Closing this issue as there is a working solution. Please let me know if you run into more problems when using this sdk with libtorch. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
The bug manifests as undefined references to specific functions in the AWS SDK during the linking stage of your project build.
Expected Behavior
I expect the project to be built successfully.
Current Behavior
Reproduction Steps
CMakeLists.txt :
Possible Solution
No response
Additional Information/Context
Only aws getobject is used in the actual source code.There is no problem when aws and libtorch build projects separately,This problem arises when the combination comes together.libtorch is available in version 1.7.0
AWS CPP SDK version used
AWS CPP SDK-1.11.237
Compiler and Version used
gcc-7.3.1
Operating System and version
centos
The text was updated successfully, but these errors were encountered: