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

Extend simple lib example to support GPU inputs / outputs #579

Merged
merged 4 commits into from
Aug 26, 2019

Conversation

GuanLuo
Copy link
Contributor

@GuanLuo GuanLuo commented Aug 23, 2019

No description provided.

*buffer = (byte_size == 0) ? nullptr : malloc(byte_size);
// need to do any other book-keeping.
if (byte_size == 0) {
*buffer = nullptr;
*buffer_userp = new std::string(tensor_name);
Copy link
Contributor

Choose a reason for hiding this comment

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

*buffer_userp = nullptr when byte_size is 0. Release won't be called (will it?) and buffer_userp is just passed to release.

@@ -24,6 +24,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include <cuda_runtime_api.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Need some ifdef GPU

LOG_INFO << "Releasing buffer " << buffer << " of size " << byte_size
<< " for result '" << *name << "'";
free(buffer);
std::string memory_type_str =
Copy link
Contributor

Choose a reason for hiding this comment

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

Make this global and use it in the logging in the alloc function as well.

@@ -48,6 +69,7 @@ Usage(char** argv, const std::string& msg = std::string())
}

LOG_ERROR << "Usage: " << argv[0] << " [options]";
LOG_ERROR << "\t-g store input data in GPU";
Copy link
Contributor

Choose a reason for hiding this comment

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

"Use GPU memory for input and output tensors"

void* allocated_ptr = nullptr;
if (memory_type == TRTSERVER_MEMORY_CPU) {
allocated_ptr = malloc(byte_size);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Only use GPU if -g flag was specified

@@ -118,11 +167,15 @@ int
main(int argc, char** argv)
{
std::string model_repository_path;
bool gpu_input = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

gpu_input implies only using for input. How about "use_gpu_memory"

@deadeyegoodwin deadeyegoodwin merged commit 61aef4a into master Aug 26, 2019
@deadeyegoodwin deadeyegoodwin deleted the gluo-simple branch August 26, 2019 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants