The Moroccan dirham is a controlled currency and not usually possible to obtain outside of Morocco. The most convenient way to obtain dirhams is through an ATM. There are many banks with ATMs all over Marrakech.
Daily withdrawal limits are usually around 3,000 dirhams. Ensure you advise your card issuer that you are travelling to Morocco or they may block your card.
National currencies can be exchanged at official currency exchange offices, found at the airport, most banks and major hotels. While a lot of prices in Morocco are quoted in euros, there is no benefit to bringing euros over GBP sterling, as all major currencies are readily exchanged.
Some credit cards are accepted in larger restaurants, hotels, guest houses and the occasional shop in the souks. If hiring a car, have cash on hand to pay for petrol.