I think both work, since both forms are nominal in value (they 'act' as nouns).
Nevertheless, I'd normally use a gerund in this context, since using a full infinitive as a subject sounds a bit old fashioned to my ears.
For more information, please check the following links:
Here you'll find a comparison between gerunds and full infinitives:
I find this website quite useful (I always recommend it to my students): http://www.perfect-english-grammar.com/gerunds-and-infinitives.html
And here's a discussion about the use of gerunds or full infinitives in subject position:
Hope this helps!