Skip to content

Comments

Implemented cudaMemGetInfo for caching allocator#600

Merged
soumith merged 5 commits intotorch:masterfrom
NVIDIA:getmeminfo-fix
Nov 23, 2016
Merged

Implemented cudaMemGetInfo for caching allocator#600
soumith merged 5 commits intotorch:masterfrom
NVIDIA:getmeminfo-fix

Conversation

@borisfom
Copy link
Contributor

I tested it with test_shutdown.lua

@borisfom
Copy link
Contributor Author

@soumith, @szagoruyko : this fix is ready to go in.

THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes));
} else { /* argument was given, particular device's memory usage */
THCudaCheck(cudaSetDevice(device-1)); /* zero indexed */
THCudaCheck(cudaMemGetInfo(&freeBytes, &totalBytes));
Copy link
Member

Choose a reason for hiding this comment

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

in this whole file,
all you have to do is change this one line from cudaMemGetInfo to THCudaMemGetInfo along with a line above to get THCState. I dont see why all the other changes here are relevant or necessary, please revert those.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, me trying to avoid code duplication here led to code bloat instead :). Cleaned up.

@@ -158,12 +158,12 @@ struct THCCachingAllocator
allocated_blocks.erase(it);

Copy link
Member

Choose a reason for hiding this comment

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

i think @colesbury had some reservations about this as well. this can be greatly simplified. i'll let him comment on monday.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way to simplify it would be to introduce counter of free memory and update it on each allocation/deallocation.
That would be a sensible approach as well. I was shooting for a least intrusive method that does not add any complexity (and locks) to the main functionality.

Copy link
Contributor Author

@borisfom borisfom Nov 22, 2016

Choose a reason for hiding this comment

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

And , yes, the largest block size parameter is now unused.
@soumith , @colesbury: we can either purge it or hook it up for the user to actually get this info, let me know which way you prefer.

@soumith
Copy link
Member

soumith commented Nov 23, 2016

Thanks!

@borisfom borisfom deleted the getmeminfo-fix branch January 9, 2017 19:24
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.

2 participants